From 7dcb34559ba8d2cc0531c5398762a82381405e0c Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Mon, 24 Apr 2023 21:50:25 +0200 Subject: [PATCH] Raise error if missing token --- pyhon/connection/auth.py | 7 +++++-- setup.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyhon/connection/auth.py b/pyhon/connection/auth.py index 4ed98ea..c4d7bbc 100644 --- a/pyhon/connection/auth.py +++ b/pyhon/connection/auth.py @@ -182,13 +182,14 @@ class HonAuth: await self._error_logger(response) return "" - def _parse_token_data(self, text: str) -> None: + def _parse_token_data(self, text: str) -> bool: if access_token := re.findall("access_token=(.*?)&", text): self._access_token = access_token[0] if refresh_token := re.findall("refresh_token=(.*?)&", text): self._refresh_token = refresh_token[0] if id_token := re.findall("id_token=(.*?)&", text): self._id_token = id_token[0] + return True if access_token and refresh_token and id_token else False async def _get_token(self, url: str) -> bool: async with self._request.get(url) as response: @@ -214,7 +215,9 @@ class HonAuth: if response.status != 200: await self._error_logger(response) return False - self._parse_token_data(await response.text()) + if not self._parse_token_data(await response.text()): + await self._error_logger(response) + return False return True async def _api_auth(self) -> bool: diff --git a/setup.py b/setup.py index 7862ecd..ca6fad6 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r") as f: setup( name="pyhOn", - version="0.9.0", + version="0.9.1", author="Andre Basche", description="Control hOn devices with python", long_description=long_description,