Skip to main content

Overview

The OAuth API manages the authentication flow for adding ChatGPT accounts to Codex-LB. It supports both browser-based PKCE flow and device code flow.
All OAuth endpoints require dashboard authentication. See Dashboard Auth for login details.

POST /api/oauth/start

Initiate an OAuth flow to add a new ChatGPT account.

Request Body

string
required
OAuth method to use. Options:
  • "pkce" - Browser-based PKCE flow (recommended)
  • "device_code" - Device code flow for headless environments

Response

string
The OAuth method being used ("pkce" or "device_code")
string
For PKCE: URL to redirect the user to for authorization
string
For device code: The device code to enter at the verification URL
string
For device code: User-friendly code to display
string
For device code: URL where the user enters the code
integer
For device code: Time in seconds until the code expires
integer
For device code: Polling interval in seconds

Example Request

cURL

Example Response (PKCE)

Example Response (Device Code)

GET /api/oauth/status

Check the status of an ongoing OAuth flow.

Response

string
Current OAuth status:
  • "pending" - Waiting for user authorization
  • "completed" - Authorization successful
  • "failed" - Authorization failed
  • "none" - No active OAuth flow
string
Error message if status is "failed"

Example Request

cURL

Example Response

POST /api/oauth/complete

Complete the OAuth flow and add the account.

Request Body

string
For PKCE: Authorization code from the callback
string
For PKCE: State parameter from the callback

Response

boolean
Whether the account was successfully added
string
ID of the newly created account
string
Email address associated with the account

Example Request

cURL

Example Response

Error Codes

OAuth Flow Diagrams

PKCE Flow

Device Code Flow