Codex auth.json overwritten, KEY mix-up, or official login lost - cc-switch
Quick fix
Upgrade cc-switch to the latest version (v3.16.1 fixes the v3.16.0 KEY mix-up regression; v3.20.1/4.0 fix logout overwriting auth.json and losing… (Codex)
Symptom
Section titled “Symptom”codex第三方供应商的key无法切换,不同供应商都变成一个KEY了The KEY for a Codex third-party provider cannot be switched; all providers end up using the same KEY.
Codex stores all login credentials and API Keys in the single file `~/.codex/auth.json`. When switching providers, enabling local routing takeover, or using the “Keep official login” feature, cc-switch needs to read and write this file. Versions such as 3.16.0 had a regression that wrote the active KEY back to other providers’ snapshots during a switch, or carried existing account data into auth.json when creating an official account. This caused different provider KEYs to become identical or a new account to be overwritten by an old one. Another common case occurs when exiting cc-switch: the proxy takeover restore logic uses an old snapshot from startup to overwrite auth.json, wiping ChatGPT credentials added by a later login. The symptom is having to log in again after every restart.
Upgrade cc-switch to the latest version now: v3.16.1 fixes the “switch overwrites auth.json / KEY mix-up” regression introduced in 3.16.0. v3.20.1 and v4.0 further changed this to replace only key fields instead of rewriting the whole file; official login is stashed in `~/.cc-switch/codex-login-stash.json` and automatically restored when switching back.
If you cannot upgrade yet, first turn off “Keep official login when switching to third-party” under “Codex App Enhancements”, then fully exit and restart cc-switch and Codex. Check whether the KEYs still overwrite one another.
For cases where official login is cleared after restart, make sure you have upgraded to v3.16.3 or later. That version fixes the issue where a restart with takeover active overwrote the live configuration with an old snapshot.
To switch between multiple official ChatGPT accounts, create a separate OpenAI Official provider for each account. If “Session expired” persists, run `codex login` in a terminal to refresh the token, then fully exit and reopen cc-switch.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 30 real issues
- #46正常配置保存报错
- #129保存失败:创建临时文件失败: /Users/moss/.codex/auth.json.tmp.1760581097714113000: Permission denied (os error 13)
- #188总是会出现登录codex覆盖前一个配置的情况
- #290codex auth.json内配置的api密钥无法被识别
- #359请问官方登录的codex 可以添加直接获取auth.json吗
- #717cc switch支持Sign in with ChatGPT么?
- #809cc-switch overrides Gemini CLI Google auth config and forces API mode
- #999配置了多个codex官方auth.json,vscode扩展无法直接切换吗?
- #1343opencode收集的数据不全,应该收集~/.local/share/opencode/auth.json目录数据
- #2157今天打开 cc switch后,codex得官方渠道上一直有一个 会话已过期,无法消除
- #2895OpenCode不支持内置供应商
- #2977codex-cli 0.132.0 切换实效
- #3451更新3.16.0版本后无法切号,新建路由配置auth.json始终写入已有账号的json内容,等于无法新建账号,3.15.0版本没有这个问题
- #34913.16.0版本切换服务商会覆盖auth.json中的OPENAI_API_KEY
- #3505codex第三方供应商的key无法切换。不同base_url的key都变成一样了
- #3543codex掉登录
- #3657codex桌面端接入deepseek模型后,在codex上模型显示自定义,无法切换 deepseek flash 和 pro 模型
- #3672codex 同一个应商切换模型问题
- #3919配置了xiaomi mimo的模型,但是在codex桌面端选择模型时无法选择
- #4099重启电脑后,codex auth官方登录被清空了
- #4548codex不可切换模型
- #4688codex每次打开,都要登录chatgpt
- #4881连了自定义模型之后,切换不了模型
- #5086codex第三方供应商的key无法切换,不同供应商都变成一个KEY了
- #5161codex客户端第三方多模型选择能力不显示
- #5866api key 混乱
- #5885Codex OAuth: Team workspace members overwrite each other in OAuth Auth Center
- #6000彻底退出ccswitch和codex时,第二次打开要求重新登录chatgpt账号
- #7042GPT 切换另外配置的时候再切回来,登录信息会丢失,导致要重新登录。
- #7105[Feature] Codex unbound Official / auth snapshot 模式支持 OAuth Token 到期前自动刷新
- After signing in to Codex with Sign in with ChatGPT, does cc-switch’s “Test Model” report a missing API Key?
- Proxy mode and the test model feature do not support official ChatGPT account login, to prevent account bans. Run `codex` directly in a terminal to complete the official login flow; you can then switch normally in cc-switch.
- After configuring a third-party model, does the Codex desktop model selector show “Custom” and refuse to switch?
- This is a limitation of the Codex desktop app itself: without an official ChatGPT login session, it falls back to the official default model. To resolve this, first sign in to an official account in the desktop app. Then enable “Keep official login when switching to third-party” in cc-switch settings, make sure local routing is enabled for the third-party provider, and fully restart Codex.
- After enabling “Keep official login”, did the KEYs for different providers become identical?
- This is a known bug in some versions: enabling the feature pins one provider’s API and overwrites other configurations. Turn off the setting or upgrade to v3.17.0+ and try again.
- After switching configurations in cc-switch, do I need to restart Codex for the change to take effect?
- Yes. Codex does not support hot switching. After modifying auth.json, you must fully exit and restart the Codex desktop app or CLI.
- Do multiple member accounts in the same Team/Business workspace overwrite each other in OAuth Auth Center?
- cc-switch currently uses the workspace-level `chatgpt_account_id` as the storage key, so different members in the same workspace conflict. This issue is not fixed yet. For now, use the classic “unbound Official / auth snapshot” mode to create a separate provider for each member.
- Why does the Codex interface hide my official ChatGPT login status while I’m using a third-party API?
- This is behavior of the official Codex client: it hides the official login session and official plugins when using a third-party provider. cc-switch only ensures credentials are preserved when you switch back to the official provider, so you do not need to log in again.
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.