Fix sync TUI freeze by completing auth before starting dashboard
This commit is contained in:
@@ -715,6 +715,24 @@ def sync(
|
||||
else:
|
||||
# Default: Launch interactive TUI dashboard
|
||||
from .sync_dashboard import run_dashboard_sync
|
||||
from src.services.microsoft_graph.auth import has_valid_cached_token
|
||||
|
||||
# Check if we need to authenticate before starting the TUI
|
||||
# This prevents the TUI from appearing to freeze during device flow auth
|
||||
if not demo:
|
||||
scopes = [
|
||||
"https://graph.microsoft.com/Calendars.Read",
|
||||
"https://graph.microsoft.com/Mail.ReadWrite",
|
||||
]
|
||||
if not has_valid_cached_token(scopes):
|
||||
click.echo("Authentication required. Please complete the login flow...")
|
||||
try:
|
||||
# This will trigger the device flow auth in the console
|
||||
get_access_token(scopes)
|
||||
click.echo("Authentication successful! Starting dashboard...")
|
||||
except Exception as e:
|
||||
click.echo(f"Authentication failed: {e}")
|
||||
return
|
||||
|
||||
sync_config = {
|
||||
"org": org,
|
||||
@@ -936,6 +954,27 @@ def status():
|
||||
def interactive(org, vdir, notify, dry_run, demo):
|
||||
"""Launch interactive TUI dashboard for sync operations."""
|
||||
from .sync_dashboard import run_dashboard_sync
|
||||
from src.services.microsoft_graph.auth import (
|
||||
has_valid_cached_token,
|
||||
get_access_token,
|
||||
)
|
||||
|
||||
# Check if we need to authenticate before starting the TUI
|
||||
# This prevents the TUI from appearing to freeze during device flow auth
|
||||
if not demo:
|
||||
scopes = [
|
||||
"https://graph.microsoft.com/Calendars.Read",
|
||||
"https://graph.microsoft.com/Mail.ReadWrite",
|
||||
]
|
||||
if not has_valid_cached_token(scopes):
|
||||
click.echo("Authentication required. Please complete the login flow...")
|
||||
try:
|
||||
# This will trigger the device flow auth in the console
|
||||
get_access_token(scopes)
|
||||
click.echo("Authentication successful! Starting dashboard...")
|
||||
except Exception as e:
|
||||
click.echo(f"Authentication failed: {e}")
|
||||
return
|
||||
|
||||
sync_config = {
|
||||
"org": org,
|
||||
|
||||
Reference in New Issue
Block a user