module

Crig::Providers::ChatGPT::OAuth

OAuth device-code authentication for ChatGPT.

Flow:

  1. Request a device code from OpenAI's auth endpoint
  2. Show the user the verification URL and code
  3. Poll for authorization (user visits URL, enters code)
  4. Exchange the authorization code for access/refresh tokens
  5. Cache tokens to disk for reuse
  6. Automatically refresh expired tokens

Constants

AUTH_BASE = "https://auth.openai.com"
CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann"
DEVICE_CODE_POLL_SLEEP_SECONDS = 5_u64
DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60_i64
DEVICE_CODE_URL = "https://auth.openai.com/api/accounts/deviceauth/usercode"
DEVICE_TOKEN_URL = "https://auth.openai.com/api/accounts/deviceauth/token"
DEVICE_VERIFY_URL = "https://auth.openai.com/codex/device"
OAUTH_TOKEN_URL = "https://auth.openai.com/oauth/token"
TOKEN_EXPIRY_SKEW_SECONDS = 60_i64

Nested types