Skip to main content

Module codex_auth_import

Module codex_auth_import 

Source
Expand description

Import ChatGPT OAuth credentials from the Codex CLI’s ~/.codex/auth.json.

This implements the “reuse Codex auth.json” integration path described in the DeepWiki analysis of openai/codex: a third-party coding harness can read the OAuth tokens that codex login persisted and use them directly, avoiding a separate browser OAuth dance.

§How it works

  1. codex login stores ChatGPT OAuth tokens (id_token, access_token, refresh_token) and a derived OPENAI_API_KEY in $CODEX_HOME/auth.json (~/.codex/auth.json by default).
  2. VT Code reads that file, parses the token data, and converts it into an OpenAIChatGptSession that the OpenAI provider can use directly.
  3. VT Code deliberately does not rotate Codex-owned refresh tokens. Copying or redeeming them could race Codex’s refresh cycle or invalidate Codex-maintained credentials. Instead, CodexAuthJsonRefresher re-reads the auth.json file — which Codex refreshes independently — to obtain fresh tokens when VT Code’s session needs a refresh.

Based on patterns from openai/codex (Apache-2.0). Copyright 2025 OpenAI. See the repository THIRD-PARTY-NOTICES file for full attribution.

Structs§

CodexAuthJsonRefresher
A session refresher that re-reads Codex’s auth.json to obtain fresh tokens.

Functions§

codex_auth_json_exists
Check whether Codex’s auth.json exists on disk.
codex_auth_json_path
Path to Codex’s auth.json.
codex_auth_json_refresher
Create a shared CodexAuthJsonRefresher handle for use with the external constructor on crate::OpenAIChatGptAuthHandle.
codex_home_dir
Resolve the Codex home directory (CODEX_HOME env var or ~/.codex).
try_load_codex_chatgpt_session
Try to load a ChatGPT session from Codex’s auth.json.