The Codex CLI supports authenticating with a ChatGPT Pro/Teams account via OAuth 2.0 with PKCE. Tokens are stored in ~/.codex/auth.json.
Token Loading & Refresh
The 8-day stale threshold comes from the Codex CLI Rust source (codex-rs/core/src/auth.rs). Tokens older than 8 days trigger an automatic refresh.
Where OAuth shows up in this world
openai.com itself uses long-lived API keys, not OAuth. OAuth bearer tokens appear when you target hosts that front the OpenAI-compatible wire shape behind a corporate identity layer: ChatGPT Pro endpoints (cwkPippa's Codex vessel uses these), Google's Cloud Code Assist (cwkPippa's Gemini vessel), Azure OpenAI behind Entra ID, or any enterprise gateway that requires user-context auth.
The pattern: store a refresh token, exchange it for a short-lived bearer (5-60 min), put the bearer in Authorization: Bearer ..., refresh on 401. cwkPippa's adapter wraps this in a try-once-then-refresh-and-retry-once helper so the rest of the code doesn't think about token lifecycles.