1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00
This commit is contained in:
Paulus Schoutsen
2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View File

@@ -11,15 +11,18 @@ from .const import DOMAIN
def initialize(hass, client_id, client_secret):
"""Initialize a local auth provider."""
config_flow.register_flow_implementation(
hass, DOMAIN, 'configuration.yaml',
hass,
DOMAIN,
"configuration.yaml",
partial(generate_auth_url, client_id),
partial(resolve_auth_code, hass, client_id, client_secret)
partial(resolve_auth_code, hass, client_id, client_secret),
)
async def generate_auth_url(client_id, flow_id):
"""Generate an authorize url."""
from nest.nest import AUTHORIZE_URL
return AUTHORIZE_URL.format(client_id, flow_id)
@@ -41,5 +44,6 @@ async def resolve_auth_code(hass, client_id, client_secret, code):
except AuthorizationError as err:
if err.response.status_code == 401:
raise config_flow.CodeInvalid()
raise config_flow.NestAuthError('Unknown error: {} ({})'.format(
err, err.response.status_code))
raise config_flow.NestAuthError(
"Unknown error: {} ({})".format(err, err.response.status_code)
)