Skip to content

Commit

Permalink
Add arg to set token type when processing token.
Browse files Browse the repository at this point in the history
  • Loading branch information
tehkillerbee committed Apr 2, 2024
1 parent 6fb5289 commit 3f7910c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 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,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"]
Expand All @@ -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"])
Expand Down

0 comments on commit 3f7910c

Please sign in to comment.