feat: change OAuth login command for providers
This commit is contained in:
parent
c6915d27e9
commit
09c7e7aded
@ -597,6 +597,7 @@ That's it! Environment variables, model prefixing, config matching, and `nanobot
|
||||
| `nanobot agent --logs` | Show runtime logs during chat |
|
||||
| `nanobot gateway` | Start the gateway |
|
||||
| `nanobot status` | Show status |
|
||||
| `nanobot provider login openai-codex` | OAuth login for providers |
|
||||
| `nanobot channels login` | Link WhatsApp (scan QR) |
|
||||
| `nanobot channels status` | Show channel status |
|
||||
|
||||
|
||||
@ -860,9 +860,12 @@ def status():
|
||||
# OAuth Login
|
||||
# ============================================================================
|
||||
|
||||
provider_app = typer.Typer(help="Manage providers")
|
||||
app.add_typer(provider_app, name="provider")
|
||||
|
||||
@app.command()
|
||||
def login(
|
||||
|
||||
@provider_app.command("login")
|
||||
def provider_login(
|
||||
provider: str = typer.Argument(..., help="OAuth provider to authenticate with (e.g., 'openai-codex')"),
|
||||
):
|
||||
"""Authenticate with an OAuth provider."""
|
||||
@ -870,19 +873,24 @@ def login(
|
||||
|
||||
if provider == "openai-codex":
|
||||
try:
|
||||
from oauth_cli_kit import get_token as get_codex_token
|
||||
|
||||
console.print("[cyan]Starting OpenAI Codex authentication...[/cyan]")
|
||||
console.print("A browser window will open for you to authenticate.\n")
|
||||
|
||||
token = get_codex_token()
|
||||
|
||||
if token and token.access:
|
||||
console.print(f"[green]✓ Successfully authenticated with OpenAI Codex![/green]")
|
||||
console.print(f"[dim]Account ID: {token.account_id}[/dim]")
|
||||
else:
|
||||
from oauth_cli_kit import get_token, login_oauth_interactive
|
||||
token = None
|
||||
try:
|
||||
token = get_token()
|
||||
except Exception:
|
||||
token = None
|
||||
if not (token and token.access):
|
||||
console.print("[cyan]No valid token found. Starting interactive OAuth login...[/cyan]")
|
||||
console.print("A browser window may open for you to authenticate.\n")
|
||||
token = login_oauth_interactive(
|
||||
print_fn=lambda s: console.print(s),
|
||||
prompt_fn=lambda s: typer.prompt(s),
|
||||
)
|
||||
if not (token and token.access):
|
||||
console.print("[red]✗ Authentication failed[/red]")
|
||||
raise typer.Exit(1)
|
||||
console.print("[green]✓ Successfully authenticated with OpenAI Codex![/green]")
|
||||
console.print(f"[dim]Account ID: {token.account_id}[/dim]")
|
||||
except ImportError:
|
||||
console.print("[red]oauth_cli_kit not installed. Run: pip install oauth-cli-kit[/red]")
|
||||
raise typer.Exit(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user