Skip to content

Commit

Permalink
Merge pull request #247 from tamland/fix/token_type
Browse files Browse the repository at this point in the history
Fix/token type
  • Loading branch information
tehkillerbee authored Apr 2, 2024
2 parents 6fb5289 + 8c77aa4 commit 5a08e91
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -647,14 +647,18 @@ 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"]
Expand All @@ -668,7 +672,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"])
Expand Down

0 comments on commit 5a08e91

Please sign in to comment.