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

Add optional fn_print to Session::login_session_file #283

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
7 changes: 5 additions & 2 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,15 @@ def login_session_file(
self,
session_file: Path,
do_pkce: Optional[bool] = False,
fn_print: Callable[[str], None] = print
) -> bool:
"""Logs in to the TIDAL api using an existing OAuth/PKCE session file. If no
session json file exists, a new one will be created after successful login.

:param session_file: The session json file
:param do_pkce: Perform PKCE login. Default: Use OAuth logon
:param fn_print: A function which will be called to print the challenge text,
defaults to `print()`.
:return: Returns true if we think the login was successful.
"""
self.load_session_from_file(session_file)
Expand All @@ -460,10 +463,10 @@ def login_session_file(
if not self.check_login():
if do_pkce:
log.info("Creating new session (PKCE)...")
self.login_pkce()
self.login_pkce(fn_print=fn_print)
else:
log.info("Creating new session (OAuth)...")
self.login_oauth_simple()
self.login_oauth_simple(function=fn_print)
tehkillerbee marked this conversation as resolved.
Show resolved Hide resolved

if self.check_login():
log.info("TIDAL Login OK")
Expand Down
Loading