mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-12-22 02:35:32 +00:00
Set refresh token
This commit is contained in:
parent
df27729c2e
commit
767cbe35de
|
@ -25,6 +25,7 @@ class HonAPI:
|
|||
password: str = "",
|
||||
anonymous: bool = False,
|
||||
mobile_id: str = "",
|
||||
refresh_token: str = "",
|
||||
session: Optional[ClientSession] = None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
@ -32,6 +33,7 @@ class HonAPI:
|
|||
self._password: str = password
|
||||
self._anonymous: bool = anonymous
|
||||
self._mobile_id: str = mobile_id
|
||||
self._refresh_token: str = refresh_token
|
||||
self._hon_handler: Optional[HonConnectionHandler] = None
|
||||
self._hon_anonymous_handler: Optional[HonAnonymousConnectionHandler] = None
|
||||
self._session: Optional[ClientSession] = session
|
||||
|
@ -71,7 +73,10 @@ class HonAPI:
|
|||
).create()
|
||||
if not self._anonymous:
|
||||
self._hon_handler = await HonConnectionHandler(
|
||||
self._email, self._password, self._session, mobile_id=self._mobile_id
|
||||
self._email,
|
||||
self._password,
|
||||
self._session,
|
||||
mobile_id=self._mobile_id,
|
||||
).create()
|
||||
return self
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class HonAuth:
|
|||
email: str,
|
||||
password: str,
|
||||
device: HonDevice,
|
||||
refresh_token: str = "",
|
||||
) -> None:
|
||||
self._session = session
|
||||
self._request = HonAuthConnectionHandler(session)
|
||||
|
@ -57,6 +58,7 @@ class HonAuth:
|
|||
self._device = device
|
||||
self._expires: datetime = datetime.utcnow()
|
||||
self._auth = HonAuthData()
|
||||
self._auth.refresh_token = refresh_token
|
||||
|
||||
@property
|
||||
def cognito_token(self) -> str:
|
||||
|
|
|
@ -23,12 +23,14 @@ class HonConnectionHandler(ConnectionHandler):
|
|||
email: str,
|
||||
password: str,
|
||||
mobile_id: str = "",
|
||||
refresh_token: str = "",
|
||||
session: Optional[aiohttp.ClientSession] = None,
|
||||
) -> None:
|
||||
super().__init__(session=session)
|
||||
self._device: HonDevice = HonDevice(mobile_id)
|
||||
self._email: str = email
|
||||
self._password: str = password
|
||||
self._refresh_token: str = refresh_token
|
||||
if not self._email:
|
||||
raise HonAuthenticationError("An email address must be specified")
|
||||
if not self._password:
|
||||
|
@ -47,7 +49,13 @@ class HonConnectionHandler(ConnectionHandler):
|
|||
|
||||
async def create(self) -> Self:
|
||||
await super().create()
|
||||
self._auth = HonAuth(self.session, self._email, self._password, self._device)
|
||||
self._auth = HonAuth(
|
||||
self.session,
|
||||
self._email,
|
||||
self._password,
|
||||
self._device,
|
||||
refresh_token=self._refresh_token,
|
||||
)
|
||||
return self
|
||||
|
||||
async def _check_headers(self, headers: Dict[str, str]) -> Dict[str, str]:
|
||||
|
|
|
@ -22,6 +22,7 @@ class Hon:
|
|||
password: Optional[str] = "",
|
||||
session: Optional[ClientSession] = None,
|
||||
mobile_id: str = "",
|
||||
refresh_token: str = "",
|
||||
test_data_path: Optional[Path] = None,
|
||||
):
|
||||
self._email: Optional[str] = email
|
||||
|
@ -31,6 +32,7 @@ class Hon:
|
|||
self._api: Optional[HonAPI] = None
|
||||
self._test_data_path: Path = test_data_path or Path().cwd()
|
||||
self._mobile_id: str = mobile_id
|
||||
self._refresh_token: str = refresh_token
|
||||
|
||||
async def __aenter__(self) -> Self:
|
||||
return await self.create()
|
||||
|
@ -63,7 +65,11 @@ class Hon:
|
|||
|
||||
async def create(self) -> Self:
|
||||
self._api = await HonAPI(
|
||||
self.email, self.password, session=self._session
|
||||
self.email,
|
||||
self.password,
|
||||
session=self._session,
|
||||
mobile_id=self._mobile_id,
|
||||
refresh_token=self._refresh_token,
|
||||
).create()
|
||||
await self.setup()
|
||||
return self
|
||||
|
|
Loading…
Reference in a new issue