Expand description
OpenAI ChatGPT subscription OAuth flow and secure session storage.
This module implements an OAuth 2.0 PKCE authorization-code flow for ChatGPT
subscription auth, mirroring the flow used by openai/codex. By default VT
Code reuses the Codex CLI’s public PKCE OAuth client identity (no client
secret — the ID is not a secret by OAuth 2.1 design). This is an unofficial
compatibility mechanism: OpenAI has not documented or guaranteed third-party
reuse of this client identity, and a public client ID is not authorization
to reuse another tool’s OAuth registration. This allows ChatGPT subscription
login to work without the Codex CLI installed.
Organizations with their own OpenAI-issued client can override via
VTCODE_OPENAI_OAUTH_CLIENT_ID / VTCODE_OPENAI_OAUTH_ORIGINATOR.
- OAuth authorization-code flow with PKCE
- refresh-token exchange
- token exchange for an OpenAI API-key-style bearer token
- secure storage in keyring or encrypted file storage
Based on patterns from openai/codex (Apache-2.0). Copyright 2025 OpenAI.
See the repository THIRD-PARTY-NOTICES file for full attribution.
Re-exports§
pub use super::credentials::AuthCredentialsStoreMode;
Structs§
- OpenAI
Chat GptAuth Handle - Runtime auth state shared by OpenAI provider instances.
- OpenAI
Chat GptSession - Stored OpenAI ChatGPT subscription session.
- OpenAI
Credential Overview - Redacted summary of available OpenAI credentials for CLI/TUI display.
Enums§
- OpenAI
Chat GptAuth Status - Generic auth status reused by slash auth/status output.
- OpenAI
Chat GptSession Provenance - Where the ChatGPT session originated — used by CLI/TUI to render accurate status without directly inspecting the filesystem.
- OpenAI
Resolved Auth - OpenAI auth resolution chosen for the current runtime.
- OpenAI
Resolved Auth Source
Traits§
- OpenAI
Chat GptSession Refresher - Host-provided refresher for externally managed ChatGPT auth tokens.
Functions§
- clear_
openai_ chatgpt_ session - clear_
openai_ chatgpt_ session_ with_ mode - exchange_
openai_ chatgpt_ code_ for_ tokens - Exchange an authorization code for OAuth tokens.
- generate_
openai_ oauth_ state - get_
openai_ chatgpt_ auth_ status - get_
openai_ chatgpt_ auth_ status_ with_ mode - get_
openai_ chatgpt_ auth_ url - Build the OpenAI ChatGPT OAuth authorization URL.
- load_
openai_ chatgpt_ session - load_
openai_ chatgpt_ session_ with_ mode - parse_
openai_ chatgpt_ manual_ callback_ input - refresh_
openai_ chatgpt_ session_ with_ mode - resolve_
openai_ auth - Resolve the active OpenAI auth source for the current configuration.
- save_
openai_ chatgpt_ session - save_
openai_ chatgpt_ session_ with_ mode - summarize_
openai_ credentials