Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/token type #247

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading