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
OAuth method to use. Options:
"pkce"- Browser-based PKCE flow (recommended)"device_code"- Device code flow for headless environments
Response
The OAuth method being used (
"pkce" or "device_code")For PKCE: URL to redirect the user to for authorization
For device code: The device code to enter at the verification URL
For device code: User-friendly code to display
For device code: URL where the user enters the code
For device code: Time in seconds until the code expires
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
Current OAuth status:
"pending"- Waiting for user authorization"completed"- Authorization successful"failed"- Authorization failed"none"- No active OAuth flow
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
For PKCE: Authorization code from the callback
For PKCE: State parameter from the callback
Response
Whether the account was successfully added
ID of the newly created account
Email address associated with the account
Example Request
cURL
Example Response
Error Codes
| Code | Status | Description |
|---|---|---|
oauth_error | 502 | Upstream OAuth provider error |
not_implemented | 501 | OAuth method not implemented |
authentication_required | 401 | Dashboard session invalid or expired |
authorization_pending | 400 | Authorization not yet completed |
expired_token | 400 | Authorization code or device code expired |
OAuth Flow Diagrams
PKCE Flow
Device Code Flow
Related
- Guides → Adding Accounts - Step-by-step guide for adding accounts
- Configuration → OAuth - OAuth configuration settings
- Dashboard Auth - Dashboard authentication