From 6113735c12767a03e64dcea36da4f45ffaab5a90 Mon Sep 17 00:00:00 2001 From: tizzen33 <53906250+tizzen33@users.noreply.github.com> Date: Fri, 10 Jul 2020 13:35:21 +0200 Subject: [PATCH 1/2] Convert expires_in value to float --- homeassistant/components/toon/oauth2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/toon/oauth2.py b/homeassistant/components/toon/oauth2.py index fcd4659cea8992..522fd8d0694fd4 100644 --- a/homeassistant/components/toon/oauth2.py +++ b/homeassistant/components/toon/oauth2.py @@ -132,4 +132,6 @@ async def _token_request(self, data: dict) -> dict: resp = await session.post(self.token_url, data=data, headers=headers) resp.raise_for_status() - return cast(dict, await resp.json()) + resp_json = cast(dict, await resp.json()) + resp_json["expires_in"] = float(resp_json["expires_in"]) + return resp_json From b5895223b8a92ea723080a813281aa3ceb47b106 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 13 Jul 2020 22:42:20 +0200 Subject: [PATCH 2/2] Add code comment --- homeassistant/components/toon/oauth2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/toon/oauth2.py b/homeassistant/components/toon/oauth2.py index 522fd8d0694fd4..feeb44b656a7cd 100644 --- a/homeassistant/components/toon/oauth2.py +++ b/homeassistant/components/toon/oauth2.py @@ -133,5 +133,7 @@ async def _token_request(self, data: dict) -> dict: resp = await session.post(self.token_url, data=data, headers=headers) resp.raise_for_status() resp_json = cast(dict, await resp.json()) + # The Toon API returns "expires_in" as a string for some tenants. + # This is not according to OAuth specifications. resp_json["expires_in"] = float(resp_json["expires_in"]) return resp_json