Skip to content
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
34 changes: 20 additions & 14 deletions skore-hub-project/src/skore_hub_project/authentication/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,30 @@ def login(*, timeout=600):
"""Login to ``skore hub``."""
with suppress(HTTPError):
if Token.exists() and (Token.access() is not None):
console.print(
Panel(
Align(
"Already logged in!",
align="center",
),
title="[cyan]Skore Hub[/cyan]",
border_style="orange1",
expand=False,
padding=1,
title_align="center",
)
)
return

url, device_code, user_code = api.get_oauth_device_login()

if not open_webbrowser(url):
console.print(
Panel(
Align(
f"Please visit this [link={url}]page[/link] to login.",
align="center",
),
title="[cyan]Skore HUB[/cyan]",
border_style="orange1",
expand=False,
padding=1,
title_align="center",
)
)
console.rule("[cyan]Skore Hub[/cyan]")
console.print(
f"Opening browser; if this fails, please visit this URL to log in:\n{url}",
soft_wrap=True,
)

open_webbrowser(url)

api.get_oauth_device_code_probe(device_code, timeout=timeout)
api.post_oauth_device_callback(device_code, user_code)
Expand Down
Loading