Skip to main content

Overview

The auth command manages authentication with AI providers, supporting both OAuth flows and direct token authentication. It handles login, logout, status checking, and model listing for OAuth providers.

Usage

Subcommands

login

Authenticate with a provider using OAuth or token.

Flags

string
required
Provider to authenticate with.Supported providers:
  • openai - OpenAI (OAuth or token)
  • anthropic - Anthropic (token only)
  • google-antigravity (or antigravity) - Google Cloud Code Assist (OAuth)
boolean
default:"false"
Use device code flow for OAuth (for headless/SSH environments).Only applicable for OAuth providers (OpenAI, Google Antigravity).

logout

Remove stored credentials for one or all providers.

Flags

string
Provider to logout from. If omitted, logs out from all providers.

status

Show authentication status for all providers.
Displays:
  • Authenticated providers
  • Authentication method (oauth/token)
  • Status (active/expired/needs refresh)
  • Account details (email, account ID, project)
  • Expiration times

models

Show available models for Google Antigravity.
Lists all models available in your Cloud Code Assist project, including:
  • Model ID
  • Display name
  • Quota status
Note: Currently only supported for Google Antigravity provider.

Provider-Specific Flows

OpenAI (OAuth)

Flow:
  1. Opens browser for OAuth authentication
  2. Log in with OpenAI account
  3. Grant permissions
  4. Credentials stored automatically
  5. Config updated to use OAuth
  6. Default model set to gpt-5.2
Output:
Headless/SSH Environments:
Output:

Anthropic (Token)

Flow:
  1. Prompts for API key
  2. You paste your Anthropic API key
  3. Credentials stored securely
  4. Config updated
  5. Default model set to claude-sonnet-4.6
Output:
Get API Key: https://console.anthropic.com/settings/keys

Google Antigravity (OAuth)

Flow:
  1. Opens browser for Google OAuth
  2. Select Google account
  3. Grant Cloud Code Assist permissions
  4. Fetches project ID automatically
  5. Stores credentials
  6. Config updated
  7. Default model set to gemini-flash
Output:
Requirements:
  • Google Cloud project with Code Assist enabled
  • Billing enabled (free tier available)

Examples

Login to OpenAI

Browser opens, authenticate, then:

Login to Anthropic with Token

Login to Google Antigravity

Headless Server Login

For SSH sessions without browser access:
Output:

Check Authentication Status

Output:

List Available Models (Antigravity)

Output:

Logout from Specific Provider

Output:

Logout from All Providers

Output:

Authentication Storage

Credentials are stored securely in:
This file contains:
  • OAuth access tokens and refresh tokens
  • Pasted API tokens
  • Expiration times
  • Account metadata
Security Notes:
  • File permissions are set to 0600 (user read/write only)
  • Tokens are stored in plaintext (secure file permissions)
  • Refresh tokens enable automatic token renewal
  • OAuth tokens expire and are automatically refreshed

OAuth Token Lifecycle

Active

Token is valid and ready to use.

Needs Refresh

Token is expiring soon. PicoClaw will automatically refresh it on next use.

Expired

Token has expired. Need to re-authenticate:

Automatic Refresh

OAuth tokens are automatically refreshed when:
  • Token expires within refresh window
  • Refresh token is available
  • Next API call is made
No manual intervention required for active sessions.

Configuration Updates

When logging in, config.yaml is automatically updated:

OpenAI Login

Anthropic Login

Troubleshooting

Browser Won’t Open

Problem: OAuth browser window doesn’t open Solution: Use device code flow:

OAuth Permission Denied

Problem: “Access denied” during OAuth flow Solution:
  1. Check you’re using the correct Google/OpenAI account
  2. Ensure account has necessary permissions
  3. For Antigravity, verify Cloud Code Assist is enabled

Token Invalid

Problem: “Invalid credentials” error Solution: Re-login:

Expired OAuth Token

Problem: “Token expired” error Check status:
Solution: Re-authenticate:

Cannot Fetch Models

Problem: picoclaw auth models fails Solution:
  1. Verify logged in: picoclaw auth status
  2. Check project has Code Assist enabled
  3. Verify billing is enabled
  4. Re-login if token expired

Config Not Updated

Problem: Login succeeds but config unchanged Solution: Check file permissions:

Manual Token Configuration

Alternatively, you can manually add API keys to config.yaml:
This bypasses OAuth but requires manual key management.

Provider Comparison

Security Best Practices

  1. Logout When Done: On shared machines, logout after use
  2. Protect Auth File: Ensure proper permissions
  3. Rotate Tokens: Periodically re-authenticate
  4. Monitor Usage: Check auth status regularly

Exit Codes

  • 0: Success
  • 1: Error (invalid provider, authentication failed, network error)

See Also