Fix for starline authorization (#39674)

This commit is contained in:
Egor Shilyaev 2020-09-05 19:40:39 +05:00 committed by GitHub
parent b860caa631
commit cdc93d7110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,9 +174,11 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_authenticate_app(self, error=None):
"""Authenticate application."""
try:
self._app_code = self._auth.get_app_code(self._app_id, self._app_secret)
self._app_token = self._auth.get_app_token(
self._app_id, self._app_secret, self._app_code
self._app_code = await self.hass.async_add_executor_job(
self._auth.get_app_code, self._app_id, self._app_secret
)
self._app_token = await self.hass.async_add_executor_job(
self._auth.get_app_token, self._app_id, self._app_secret, self._app_code
)
return self._async_form_auth_user(error)
except Exception as err: # pylint: disable=broad-except
@ -186,7 +188,8 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_authenticate_user(self, error=None):
"""Authenticate user."""
try:
state, data = self._auth.get_slid_user_token(
state, data = await self.hass.async_add_executor_job(
self._auth.get_slid_user_token,
self._app_token,
self._username,
self._password,
@ -221,7 +224,9 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._slnet_token,
self._slnet_token_expires,
self._user_id,
) = self._auth.get_user_id(self._user_slid)
) = await self.hass.async_add_executor_job(
self._auth.get_user_id, self._user_slid
)
return self.async_create_entry(
title=f"Application {self._app_id}",