Skip to main content
The OAuth endpoints handle authentication flows for providers that use OAuth 2.0, including Anthropic (Claude), Google (Gemini), Codex, and others.

OAuth Flow Overview

  1. Client requests authorization URL from management API
  2. User opens URL and completes OAuth flow with provider
  3. Provider redirects to callback with code and state
  4. Client posts callback data to management API
  5. Management API writes callback file for processing
  6. Client polls for authentication status

Supported Providers

  • anthropic / claude - Anthropic Claude API
  • codex / openai - OpenAI Codex API
  • gemini / google - Google Gemini API
  • antigravity / anti-gravity - AntiGravity API
  • qwen - Qwen API
  • iflow / i-flow - iFlow API
  • kimi - Kimi API

Get Authorization URL

Get the OAuth authorization URL for a specific provider.
endpoint
/v0/management/{provider}-auth-url

Available Endpoints

  • GET /v0/management/anthropic-auth-url
  • GET /v0/management/codex-auth-url
  • GET /v0/management/gemini-cli-auth-url
  • GET /v0/management/antigravity-auth-url
  • GET /v0/management/qwen-auth-url
  • GET /v0/management/kimi-auth-url
  • GET /v0/management/iflow-auth-url

Request

Response

string
OAuth authorization URL to redirect user to
string
OAuth state parameter for CSRF protection (store this for callback validation)
number
Unix timestamp when the state expires (10 minutes from creation)

Submit OAuth Callback

endpoint
/v0/management/oauth-callback
Submits the OAuth callback data received from the provider after user authorization.

Request

Request Body

Response

string
Status of callback processing (“ok” or “error”)

Error Responses

Invalid State

Unknown/Expired State

Already Completed

Provider Mismatch

Get Authentication Status

endpoint
/v0/management/get-auth-status
Check the status of OAuth authentication flows. Used for polling after submitting callback.

Request

Query Parameters

string
Filter by provider name
string
Check specific OAuth session by state

Response

object[]
List of active OAuth sessions
string
Provider name
string
OAuth state parameter
string
Session status (empty = pending, otherwise error message or “completed”)
number
Unix timestamp when session was created
number
Unix timestamp when session expires

OAuth Session Management

Session Lifecycle

  1. Created - Session registered when auth URL requested
  2. Pending - Waiting for callback (status = "")
  3. Completed - Callback received and processed (session deleted)
  4. Error - Callback failed (status contains error message)
  5. Expired - Session TTL exceeded (automatically cleaned up)

Session TTL

  • Default TTL: 10 minutes from creation
  • Automatic cleanup: Expired sessions purged periodically
  • State validation: Must be alphanumeric with -, _, . only
  • Max length: 128 characters

State Security

The state parameter:
  • Must be provided in both auth URL request and callback
  • Used for CSRF protection
  • Cannot contain path separators (/, \)
  • Cannot contain .. (path traversal)
  • Must match pattern: [a-zA-Z0-9._-]+

Complete OAuth Flow Example

Step 1: Request Authorization URL

Step 2: User Completes OAuth Flow

User opens auth_url in browser and authorizes the application. Provider redirects to callback URL:

Step 3: Submit Callback

Step 4: Poll for Completion

OAuth Callback File Format

When callback is received, the management API writes a file: Location: {auth-dir}/.oauth-{provider}-{state}.oauth Format:
The authentication system monitors this directory and processes new OAuth files automatically.

Alternative: Submit via Redirect URL

You can submit the entire redirect URL instead of parsing code/state:
The API will parse the query parameters automatically.

Error Handling

Provider Errors

If the provider returns an error:
The error is recorded in the OAuth session and written to the callback file.

Session Expiration

If the state has expired (>10 minutes since auth URL request):
The client must request a new authorization URL and restart the flow.

Next Steps