diff options
author | Andre Basche <andre.basche@gmail.com> | 2024-08-14 22:42:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 22:42:39 +0200 |
commit | 59e3d9949f8a342e05daba70451196e7497cacb2 (patch) | |
tree | 2d32fb0f865ff1368bcd43ce5da4c2cdba26a677 /pyhon | |
parent | 63752e13d6c8e74284ad72e04306e9fedde58b40 (diff) | |
parent | 3f39be53f31885fb84d72f91fb4123c2e39e7156 (diff) |
Update for new hOn login
Diffstat (limited to 'pyhon')
-rw-r--r-- | pyhon/connection/auth.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pyhon/connection/auth.py b/pyhon/connection/auth.py index 2096010..3ab491c 100644 --- a/pyhon/connection/auth.py +++ b/pyhon/connection/auth.py | |||
@@ -120,18 +120,23 @@ class HonAuth: | |||
120 | async with self._request.get(url) as response: | 120 | async with self._request.get(url) as response: |
121 | text = await response.text() | 121 | text = await response.text() |
122 | self._expires = datetime.utcnow() | 122 | self._expires = datetime.utcnow() |
123 | login_url: List[str] = re.findall("url = '(.+?)'", text) | 123 | login_url: List[str] = re.findall("(?:url|href) ?= ?'(.+?)'", text) |
124 | if not login_url: | 124 | if not login_url: |
125 | if "oauth/done#access_token=" in text: | 125 | if "oauth/done#access_token=" in text: |
126 | self._parse_token_data(text) | 126 | self._parse_token_data(text) |
127 | raise exceptions.HonNoAuthenticationNeeded() | 127 | raise exceptions.HonNoAuthenticationNeeded() |
128 | await self._error_logger(response) | 128 | await self._error_logger(response) |
129 | # As of July 2024 the login page has changed, and we started getting a /NewhOnLogin based relative URL in JS to parse | ||
130 | if login_url[0].startswith("/NewhOnLogin"): | ||
131 | # Force use of the old login page to avoid having to make the new one work.. | ||
132 | login_url[0] = f"{const.AUTH_API}/s/login{login_url[0]}" | ||
129 | return login_url[0] | 133 | return login_url[0] |
130 | 134 | ||
131 | async def _manual_redirect(self, url: str) -> str: | 135 | async def _manual_redirect(self, url: str) -> str: |
132 | async with self._request.get(url, allow_redirects=False) as response: | 136 | async with self._request.get(url, allow_redirects=False) as response: |
133 | if not (new_location := response.headers.get("Location", "")): | 137 | new_location = response.headers.get("Location", "") |
134 | await self._error_logger(response) | 138 | if not new_location: |
139 | return url | ||
135 | return new_location | 140 | return new_location |
136 | 141 | ||
137 | async def _handle_redirects(self, login_url: str) -> str: | 142 | async def _handle_redirects(self, login_url: str) -> str: |