mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-11-28 00:10:50 +01:00
Fix session issues
This commit is contained in:
parent
46e6a85e84
commit
6b2c60d552
@ -86,7 +86,9 @@ class HonAuth:
|
||||
):
|
||||
await self._error_logger(redirect2)
|
||||
return False
|
||||
async with self._session.get(URL(url, encoded=True)) as login_screen:
|
||||
async with self._session.get(
|
||||
URL(url, encoded=True), headers={"user-agent": const.USER_AGENT}
|
||||
) as login_screen:
|
||||
self._called_urls.append(
|
||||
(login_screen.status, login_screen.request_info.url)
|
||||
)
|
||||
|
@ -17,13 +17,13 @@ class HonBaseConnectionHandler:
|
||||
self._auth = None
|
||||
|
||||
async def __aenter__(self):
|
||||
self._session = aiohttp.ClientSession()
|
||||
return await self.create()
|
||||
|
||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||
await self.close()
|
||||
|
||||
async def create(self):
|
||||
self._session = aiohttp.ClientSession(headers=self._HEADERS)
|
||||
return self
|
||||
|
||||
@asynccontextmanager
|
||||
@ -75,7 +75,7 @@ class HonConnectionHandler(HonBaseConnectionHandler):
|
||||
self._request_headers["id-token"] = self._auth.id_token
|
||||
else:
|
||||
raise HonAuthenticationError("Can't login")
|
||||
return headers | self._request_headers
|
||||
return self._HEADERS | headers | self._request_headers
|
||||
|
||||
@asynccontextmanager
|
||||
async def _intercept(self, method, *args, loop=0, **kwargs):
|
||||
@ -95,6 +95,8 @@ class HonConnectionHandler(HonBaseConnectionHandler):
|
||||
response.status,
|
||||
await response.text(),
|
||||
)
|
||||
self._request_headers = {}
|
||||
self._session.cookie_jar.clear_domain(const.AUTH_API.split("/")[-2])
|
||||
await self.create()
|
||||
async with self._intercept(
|
||||
method, *args, loop=loop + 1, **kwargs
|
||||
|
Loading…
Reference in New Issue
Block a user