Your access token could not be refreshed - Codex
Quick fix
Upgrade cc-switch to v3.17.0+, which fixes the PROXY_MANAGED placeholder polluting OAuth credentials or causing a 401 during takeover.
Symptom
Section titled “Symptom”Your access token could not be refreshed because your refresh token was already used. Please log out and sign in again.With local route takeover enabled, early cc-switch versions wrote PROXY_MANAGED into the config file (the Codex auth.json, or the Claude Code settings.json) as a placeholder marking the takeover. For Codex using an official OAuth login, that placeholder pollutes or overwrites the existing login credential so the token refresh fails. For the Codex OAuth case in Claude Code, the takeover logic wrongly deletes ANTHROPIC_AUTH_TOKEN and triggers a login prompt. And if the placeholder is left behind and sent as-is to an official endpoint or a third-party openai_chat backend, it produces a 401. The takeover logic was reworked in v3.17.0 to stop writing the placeholder and to preserve the real credentials.
Upgrade cc-switch to v3.17.0 or newer. That version reworked official session takeover routing, no longer writes the placeholder, and actively cleans up any leftover PROXY_MANAGED.
If you cannot upgrade yet and the official Codex login broke, clean the placeholder out of ~/.codex/auth.json by hand and run the OAuth login again.
// ~/.codex/auth.json{"OPENAI_API_KEY": "PROXY_MANAGED"}If Claude Code prompts you to log in, add the ANTHROPIC_AUTH_TOKEN field back into env in ~/.claude/settings.json by hand.
// ~/.claude/settings.json{"env": {"ANTHROPIC_API_KEY": "PROXY_MANAGED","ANTHROPIC_AUTH_TOKEN": ""}}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 5 real issues
- #1510[Bug] Proxy forwarder sends PROXY_MANAGED literal as API key to openai_chat backend, causing 401
- #1961Codex 接管配置不兼容 JS 版 Codex CLI,建议适配双版本或给出提示
- #2690CC 接管 Codex 路由后,Codex 提示 Your access token could not be refreshed because your refresh token was already used. Please log out and sign in again.
- #3784bug: Claude takeover removes ANTHROPIC_AUTH_TOKEN for Codex OAuth and triggers Claude Code login prompt
- #5191关于base_url异常导致模型配置错误的问题
- Why does my third-party provider (sglang, for example) report 401 Unauthorized once takeover is on?
- Early versions of the proxy forwarder sent PROXY_MANAGED to an openai_chat backend without substituting the real API key. Upgrade to v3.17.0+, or write the real API key into ~/.claude/settings.json by hand for now.
- I use the JS Codex CLI — why does takeover prompt me to log in and leave the model config not applying?
- Early versions only supported the Rust Codex config format (config.toml); the JS build cannot read the PROXY_MANAGED placeholder or .toml config. Set the environment variable CODEX_RUST=1 to standardise on the Rust build, or wait for support in a later version.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.