From b04c601ad6bdb0b2803e8fda0e902a9fb30fd8e5 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Fri, 21 Apr 2023 23:34:10 +0200 Subject: [PATCH] Add log for empty token --- pyhon/connection/auth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyhon/connection/auth.py b/pyhon/connection/auth.py index 6f26f1b..4ed98ea 100644 --- a/pyhon/connection/auth.py +++ b/pyhon/connection/auth.py @@ -228,7 +228,10 @@ class HonAuth: except json.JSONDecodeError: await self._error_logger(response) return False - self._cognito_token = json_data["cognitoUser"]["Token"] + self._cognito_token = json_data.get("cognitoUser", {}).get("Token", "") + if not self._cognito_token: + _LOGGER.error(json_data) + raise exceptions.HonAuthenticationError() return True async def authenticate(self) -> None: