aboutsummaryrefslogtreecommitdiff
path: root/pyhon
diff options
context:
space:
mode:
Diffstat (limited to 'pyhon')
-rw-r--r--pyhon/connection/auth.py11
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: