Skip to content

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)

Error output
codex第三方供应商的key无法切换,不同供应商都变成一个KEY了
English translation

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

ToolCodex
Version3.16.0 - 3.16.5(KEY 串号);3.19.1 之前(退出覆盖导致丢登录)
PlatformsWindowsmacOS

This page is distilled from 30 real issues

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.

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.