Skip to main content

Module openai_chatgpt_oauth

Module openai_chatgpt_oauth 

Source
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§

OpenAIChatGptAuthHandle
Runtime auth state shared by OpenAI provider instances.
OpenAIChatGptSession
Stored OpenAI ChatGPT subscription session.
OpenAICredentialOverview
Redacted summary of available OpenAI credentials for CLI/TUI display.

Enums§

OpenAIChatGptAuthStatus
Generic auth status reused by slash auth/status output.
OpenAIChatGptSessionProvenance
Where the ChatGPT session originated — used by CLI/TUI to render accurate status without directly inspecting the filesystem.
OpenAIResolvedAuth
OpenAI auth resolution chosen for the current runtime.
OpenAIResolvedAuthSource

Traits§

OpenAIChatGptSessionRefresher
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