Skip to content

Commit

Permalink
Use token only with --use-token flag
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 1, 2025
1 parent fb5c398 commit 46e3485
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions plextraktsync/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def env_plex_username():
help="Plex password",
default=lambda: environ.get("PLEX_PASSWORD", None),
)
@click.option(
"--use-token",
is_flag=True,
help="Use saved plex token if available",
)
def plex_login():
"""
Log in to Plex Account to obtain Access Token. Optionally can use managed user on servers that you own.
Expand Down
14 changes: 9 additions & 5 deletions plextraktsync/commands/plex_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,21 @@ def plex_login_autoconfig():
login(username, password)


def plex_login(username, password):
login(username, password)
def plex_login(username, password, use_token: bool):
token = None
if use_token:
config = factory.config
token = config["PLEX_ACCOUNT_TOKEN"]

login(username, password, token)


def login(username: str, password: str):
def login(username: str, password: str, token=None):
if factory.has_plex_token:
if not Confirm.ask(PROMPT_PLEX_RELOGIN, default=True):
return

config = factory.config
account = myplex_login(username, password, config["PLEX_ACCOUNT_TOKEN"])
account = myplex_login(username, password, token)
print(
Panel.fit(
"Login to MyPlex was successful",
Expand Down

0 comments on commit 46e3485

Please sign in to comment.