From 3f7910cd14dea08b9337558fc089fb4a43ca7417 Mon Sep 17 00:00:00 2001 From: tehkillerbee Date: Tue, 2 Apr 2024 07:19:50 +0200 Subject: [PATCH] Add arg to set token type when processing token. --- tidalapi/session.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tidalapi/session.py b/tidalapi/session.py index 70aeb8c..4931275 100644 --- a/tidalapi/session.py +++ b/tidalapi/session.py @@ -498,7 +498,7 @@ def login_pkce(self, fn_print: Callable[[str], None] = print) -> None: json: dict[str, Union[str, int]] = self.pkce_get_auth_token(url_redirect) # Parse and set tokens. - self.process_auth_token(json) + self.process_auth_token(json, is_pkce_token=True) # Swap the client_id and secret # self.client_enable_hires() @@ -647,14 +647,16 @@ def _login_with_link(self) -> Tuple[LinkLogin, concurrent.futures.Future[Any]]: def _process_link_login(self, json: JsonObj) -> None: json = self._wait_for_link_login(json) - self.process_auth_token(json) + self.process_auth_token(json, is_pkce_token=False) - def process_auth_token(self, json: dict[str, Union[str, int]]) -> None: + def process_auth_token(self, json: dict[str, Union[str, int]], is_pkce_token: bool = True) -> None: """Parses the authorization response and sets the token values to the specific variables for further usage. :param json: Parsed JSON response after login / authorization. :type json: dict[str, str | int] + :param is_pkce_token: Set true if current token is obtained using PKCE + :type is_pkce_token: bool :return: None """ self.access_token = json["access_token"] @@ -668,7 +670,7 @@ def process_auth_token(self, json: dict[str, Union[str, int]]) -> None: self.session_id = json["sessionId"] self.country_code = json["countryCode"] self.user = user.User(self, user_id=json["userId"]).factory() - self.is_pkce = True + self.is_pkce = is_pkce_token def _wait_for_link_login(self, json: JsonObj) -> Any: expiry = float(json["expiresIn"])