From 219ad5cd9e7b3b3d6380f96a70f13bf92ea9b14f Mon Sep 17 00:00:00 2001 From: Vincent Le Bourlot Date: Wed, 5 May 2021 09:19:51 +0200 Subject: [PATCH] Fix fitbit RuntimeError: I/O must be done in the executor (#50058) --- homeassistant/components/fitbit/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/fitbit/sensor.py b/homeassistant/components/fitbit/sensor.py index 8571d31bc8a..263ae24ff34 100644 --- a/homeassistant/components/fitbit/sensor.py +++ b/homeassistant/components/fitbit/sensor.py @@ -346,7 +346,7 @@ class FitbitAuthCallbackView(HomeAssistantView): self.oauth = oauth @callback - def get(self, request): + async def get(self, request): """Finish OAuth callback request.""" hass = request.app["hass"] data = request.query @@ -359,7 +359,9 @@ class FitbitAuthCallbackView(HomeAssistantView): redirect_uri = f"{get_url(hass, require_current_request=True)}{FITBIT_AUTH_CALLBACK_PATH}" 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: _LOGGER.error("Missing token: %s", error) response_message = f"""Something went wrong when