Skip to main content
Watch: I Built an AI App Without Leaving Databricks

OpenAI Codex CLI error

Codex CLI: Token exchange failed: token endpoint returned status 403 Forbidden

Error message
Token exchange failed: token endpoint returned status 403 Forbidden

Status: WorkaroundLast verified 3 documented fixes4 sources

What it means

The browser sign-in reached the local callback, but exchanging the authorization code at the OpenAI token endpoint was rejected, so codex login did not finish. A related variant is "Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)" (#5283).

Causes

  • Maintainer etraut-openai (#2414): several bugs behind this were fixed; remaining conditions mostly involve network proxies or VPNs.
  • Local firewalls or other network settings interfering with the interactive auth flow (maintainer on #5283).

How to fix it

  1. Fix 1.

    Use headless device authentication (maintainer etraut-openai on #5283; official auth docs).

    Terminal
    codex login --device-auth
  2. Fix 2.

    Behind a corporate TLS proxy or private root CA, set CODEX_CA_CERTIFICATE before logging in (official auth docs).

    Terminal
    export CODEX_CA_CERTIFICATE=/path/to/corporate-root-ca.pem
    codex login
  3. Fix 3.

    Direct codex login runs write a codex-login.log file under your log directory for debugging login failures (official auth docs).

More Codex CLI errors

All 14 Codex CLI errors

FAQ

What does "Token exchange failed: token endpoint returned status 403 Forbidden" mean in Codex CLI?

The browser sign-in reached the local callback, but exchanging the authorization code at the OpenAI token endpoint was rejected, so codex login did not finish. A related variant is "Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)" (#5283).

How do I fix "Token exchange failed: token endpoint returned status 403 Forbidden"?

There are 3 documented fixes. Start with the first: Use headless device authentication (maintainer etraut-openai on #5283; official auth docs).

Is this Codex CLI error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: Reported August 2025 (#2414); related variant on codex-cli 0.46.0 (#5283)

Sources

Last verified against 4 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.