Skip to content

Commit

Permalink
Moved LinkLogin and futures to login_oauth.
Browse files Browse the repository at this point in the history
  • Loading branch information
exislow committed Nov 13, 2024
1 parent 1720a0b commit c543cca
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,10 @@ def login_oauth(self) -> Tuple[LinkLogin, concurrent.futures.Future[Any]]:
a :class:`concurrent.futures.Future` that will poll until the login is completed, or until the link expires.
:raises: TimeoutError: If the login takes too long
"""
login, future = self._login_with_link()
return login, future
json_obj: JsonObj = self._login_with_link()
executor = concurrent.futures.ThreadPoolExecutor()

return LinkLogin(json_obj), executor.submit(self._process_link_login, json_obj)

def save_session_to_file(self, session_file: Path):
# create a new session
Expand Down Expand Up @@ -644,7 +646,7 @@ def load_session_from_file(self, session_file: Path):

return self.load_oauth_session(**args)

def _login_with_link(self) -> Tuple[LinkLogin, concurrent.futures.Future[Any]]:
def _login_with_link(self) -> JsonObj:
url = "https://auth.tidal.com/v1/oauth2/device_authorization"
params = {"client_id": self.config.client_id, "scope": "r_usr w_usr w_sub"}

Expand All @@ -655,8 +657,8 @@ def _login_with_link(self) -> Tuple[LinkLogin, concurrent.futures.Future[Any]]:
request.raise_for_status()

json = request.json()
executor = concurrent.futures.ThreadPoolExecutor()
return LinkLogin(json), executor.submit(self._process_link_login, json)

return json

def _process_link_login(self, json: JsonObj) -> None:
json = self._wait_for_link_login(json)
Expand Down

0 comments on commit c543cca

Please sign in to comment.