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
codex loginstores ChatGPT OAuth tokens (id_token,access_token,refresh_token) and a derivedOPENAI_API_KEYin$CODEX_HOME/auth.json(~/.codex/auth.jsonby default).- VT Code reads that file, parses the token data, and converts it into an
OpenAIChatGptSessionthat the OpenAI provider can use directly. - 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,
CodexAuthJsonRefresherre-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§
- Codex
Auth Json Refresher - A session refresher that re-reads Codex’s
auth.jsonto obtain fresh tokens.
Functions§
- codex_
auth_ json_ exists - Check whether Codex’s
auth.jsonexists on disk. - codex_
auth_ json_ path - Path to Codex’s
auth.json. - codex_
auth_ json_ refresher - Create a shared
CodexAuthJsonRefresherhandle for use with the external constructor oncrate::OpenAIChatGptAuthHandle. - codex_
home_ dir - Resolve the Codex home directory (
CODEX_HOMEenv var or~/.codex). - try_
load_ codex_ chatgpt_ session - Try to load a ChatGPT session from Codex’s
auth.json.