Skip to content

auth.json does not update when switching channels; editing overwrites third-party Codex key

Quick fix

No official fix. Editing a saved third-party Codex channel makes the official KEY in auth.json overwrite the third-party key. Delete and recreate the channel.

Error output
auth.json 不会随渠道改变而改变,在编辑时覆写第三方渠道的密钥
English translation

auth.json does not change when the channel changes; editing overwrites the third-party channel key

On Windows, cc-switch 3.20.0 saves a third-party Codex channel by writing the user-provided third-party OPENAI_API_KEY to the provider database and writing experimental_bearer_token to config.toml, but it does not overwrite OPENAI_API_KEY in auth.json. If official Codex login was used before, auth.json still contains the official KEY. When opening the edit screen, cc-switch appears to read the KEY from auth.json as the initial input value, so saving overwrites the third-party channel with the official KEY. Some users report that after official login, switching API and restarting Codex leaves auth.json in official login state, and manually editing auth.json does not help. Others report an invalid token error when logging in with a third-party key, indicating the request is not actually using the third-party channel. This issue remains open with no official fix.

  1. Workaround: do not edit a saved third-party channel. To change a third-party KEY, delete the channel and add it again.

  2. If providing diagnostics to maintainers, collect the provider database records before and after editing/saving as requested in #6594: settings_config.auth.OPENAI_API_KEY, whether auth.json.OPENAI_API_KEY is empty, and the effective experimental_bearer_token in config.toml.

ToolCodex
Version3.20.0
PlatformsWindows
After official login, switching API and restarting Codex still leaves auth.json in official login state, and manual edits do not work. What should I do?
This is the same issue as #6594. There is currently no working manual override. The edit screen reads the official KEY back from auth.json, and resaving overwrites the third-party key. Delete and re-add the channel, or wait for cc-switch to fix the auth.json overwrite logic.
Why does the KEY input field show the official KEY when I edit a third-party channel in cc-switch?
Because cc-switch does not overwrite auth.json when saving a third-party channel, but the edit screen reads the KEY from auth.json as the initial value. You see the official KEY, and saving overwrites the third-party channel with the official KEY.
Why does logging in to Codex with a third-party key show an invalid token?
Other users have reported the same behavior, indicating the request is not actually bypassing official login. The root cause is related to auth.json not being overwritten. There is currently no official fix.

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.