Fix fitbit RuntimeError: I/O must be done in the executor (#50058)
This commit is contained in:
parent
f88eea5275
commit
219ad5cd9e
1 changed files with 4 additions and 2 deletions
|
@ -346,7 +346,7 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
||||||
self.oauth = oauth
|
self.oauth = oauth
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def get(self, request):
|
async def get(self, request):
|
||||||
"""Finish OAuth callback request."""
|
"""Finish OAuth callback request."""
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
data = request.query
|
data = request.query
|
||||||
|
@ -359,7 +359,9 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
||||||
redirect_uri = f"{get_url(hass, require_current_request=True)}{FITBIT_AUTH_CALLBACK_PATH}"
|
redirect_uri = f"{get_url(hass, require_current_request=True)}{FITBIT_AUTH_CALLBACK_PATH}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.oauth.fetch_access_token(data.get("code"), redirect_uri)
|
result = await hass.async_add_executor_job(
|
||||||
|
self.oauth.fetch_access_token, data.get("code"), redirect_uri
|
||||||
|
)
|
||||||
except MissingTokenError as error:
|
except MissingTokenError as error:
|
||||||
_LOGGER.error("Missing token: %s", error)
|
_LOGGER.error("Missing token: %s", error)
|
||||||
response_message = f"""Something went wrong when
|
response_message = f"""Something went wrong when
|
||||||
|
|
Loading…
Add table
Reference in a new issue