Skip to content

Cannot sign in to a Codex account that uses a Google email - Codex

Quick fix

Upgrade cc-switch to v3.16.1+, or edit ~/.codex/auth.json by hand to restore auth_mode to chatgpt and clear OPENAI_API_KEY.

Error output
关闭cc switch 的codex 配置,也无法使用谷歌邮箱登录的codex账号
English translation

Even after disabling the cc-switch codex config, I still cannot sign in to the codex account that uses a Google email.

When taking over or switching Codex provider, cc-switch modifies `~/.codex/auth.json` and `config.toml`. Early versions (v3.16.0 and earlier) wrote the third-party API key straight into the `OPENAI_API_KEY` field of `auth.json`, so Codex forcibly detected `auth_mode="ApiKey"` and the official ChatGPT OAuth login state broke — leaving Fast mode unavailable, usage queries failing, or the model list blank. A leftover `OPENAI_API_KEY` also confuses the state when clearing config or switching back to an official provider.

v3.16.1 introduced per-app credential resolution and provider-scoped auth logic, fixing most of the credential overwriting. But edge cases remain — `codex resume` not reading the latest `model_provider`, or a half-expired `id_token` on the Desktop side — and still need manual intervention or a check of the local cache state.

  1. Upgrade cc-switch to v3.16.1 or newer to get per-app credential resolution and provider-scoped auth logic.

  2. To restore the official ChatGPT login state, edit `~/.codex/auth.json` by hand, set `auth_mode` to `chatgpt`, and clear `OPENAI_API_KEY`.

    // ~/.codex/auth.json
    {
    "auth_mode": "chatgpt",
    "OPENAI_API_KEY": null
    }
  3. If you use a custom provider and need to keep the official login working, pass the API key with `env_key` or `experimental_bearer_token` in `config.toml` rather than overwriting `auth.json`.

    // ~/.codex/config.toml
    [model_providers.custom]
    name = "custom"
    base_url = "https://example-gateway/v1"
    env_key = "MY_PROVIDER_API_KEY"
    requires_openai_auth = false
ToolCodex
VersionUnknown
PlatformsmacOSWindows
Why are Codex Desktop Fast mode or remote control unavailable after switching to a third-party provider?
Older cc-switch wrote the API key into `auth.json`, turning `auth_mode` into `ApiKey`, so Codex decided you were not using the official login. Upgrade to v3.16.1+ or keep `auth_mode: chatgpt` by hand.
Why can `codex resume` not use a custom provider?
`codex resume` reads the provider recorded when the session was created rather than the current top-level `model_provider` in `config.toml`. Pass `-c 'model_provider="custom"'` explicitly at launch.
Why is the Codex Desktop model picker blank?
Either the `/v1/models` response format is incompatible, or the `id_token` in `auth.json` has expired even though the `access_token` is still valid. Check the JWT `exp` field and sign 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.