Raise error if missing token
This commit is contained in:
parent
5db13a90e7
commit
7dcb34559b
2 changed files with 6 additions and 3 deletions
|
@ -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:
|
||||
|
|
2
setup.py
2
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,
|
||||
|
|
Loading…
Reference in a new issue