mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-11-28 00:10:50 +01:00
Merge pull request #29 from addshore/updatedLogin
Update for new hOn login
This commit is contained in:
commit
59e3d9949f
@ -120,18 +120,23 @@ class HonAuth:
|
|||||||
async with self._request.get(url) as response:
|
async with self._request.get(url) as response:
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
self._expires = datetime.utcnow()
|
self._expires = datetime.utcnow()
|
||||||
login_url: List[str] = re.findall("url = '(.+?)'", text)
|
login_url: List[str] = re.findall("(?:url|href) ?= ?'(.+?)'", text)
|
||||||
if not login_url:
|
if not login_url:
|
||||||
if "oauth/done#access_token=" in text:
|
if "oauth/done#access_token=" in text:
|
||||||
self._parse_token_data(text)
|
self._parse_token_data(text)
|
||||||
raise exceptions.HonNoAuthenticationNeeded()
|
raise exceptions.HonNoAuthenticationNeeded()
|
||||||
await self._error_logger(response)
|
await self._error_logger(response)
|
||||||
|
# As of July 2024 the login page has changed, and we started getting a /NewhOnLogin based relative URL in JS to parse
|
||||||
|
if login_url[0].startswith("/NewhOnLogin"):
|
||||||
|
# Force use of the old login page to avoid having to make the new one work..
|
||||||
|
login_url[0] = f"{const.AUTH_API}/s/login{login_url[0]}"
|
||||||
return login_url[0]
|
return login_url[0]
|
||||||
|
|
||||||
async def _manual_redirect(self, url: str) -> str:
|
async def _manual_redirect(self, url: str) -> str:
|
||||||
async with self._request.get(url, allow_redirects=False) as response:
|
async with self._request.get(url, allow_redirects=False) as response:
|
||||||
if not (new_location := response.headers.get("Location", "")):
|
new_location = response.headers.get("Location", "")
|
||||||
await self._error_logger(response)
|
if not new_location:
|
||||||
|
return url
|
||||||
return new_location
|
return new_location
|
||||||
|
|
||||||
async def _handle_redirects(self, login_url: str) -> str:
|
async def _handle_redirects(self, login_url: str) -> str:
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open("README.md", "r", encoding="utf-8") as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.17.4",
|
version="0.17.5",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
Loading…
Reference in New Issue
Block a user