Login failed — token exchange failed: error sending request to URL (https://auth.openai.com/oauth/token)

Open 💬 11 comments Opened Jun 6, 2026 by liuhongwei56
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

最新版本

What subscription do you have?

plus

What platform is your computer?

windows

What issue are you seeing?

错误代码
token_exchange_failed
细节
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)

What steps can reproduce the bug?

无法登入codex,网页版可以正常使用

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

11 Comments

zhanghaohao11 · 1 month ago

macOS 26.5.1
Apple Silicon
Codex CLI 0.139.0

Same issue.

Web ChatGPT works.
Desktop login fails.
CLI login fails.
Device auth fails.

Token exchange failed:
error sending request for url
https://auth.openai.com/oauth/token

zhanghaohao11 · 1 month ago

Same issue.

macOS 26.5.1
Apple Silicon
Codex CLI 0.139.0

Desktop login fails
CLI login fails
Device Auth fails

curl auth.openai.com works
curl chatgpt.com/backend-api returns cf-mitigated: challenge

etraut-openai contributor · 1 month ago

English translation:

What version of the Codex App are you using (From “About Codex” dialog)?

Latest version

What subscription do you have?

plus

What platform is your computer?

windows

What issue are you seeing?

Error code
token_exchange_failed
Details
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)

What steps can reproduce the bug?

Unable to log in to Codex; the web version works normally

What is the expected behavior?

_No response_

Additional information

_No response_

<!-- codex-issue-translator -->

juanfernandezntt · 1 month ago

same for here.... any idea?

tinsky · 1 month ago

same for my MacBook.

juanfernandezntt · 1 month ago

can any add some info? thanks

tinsky · 1 month ago

After deleting the dir "~/.codex", I could log in successfully finally. But I don't think this is a good way to solve this issue.

sunny2eastgo · 1 month ago

I can reproduce the same issue, but only when running the ChatGPT extension inside WSL Remote.

Environment

  • Windows 11 Insider (10.0.26200.8655)
  • WSL 2.7.8.0
  • Ubuntu 24.04.4 LTS
  • Kernel 6.18.33.1-1
  • VS Code 1.125.1
  • ChatGPT extension 26.616.41845
  • Bundled Codex CLI 0.142.0-alpha.6
  • ChatGPT Plus

Behavior

Windows VS Code authenticates successfully.

The same account fails only when VS Code is connected to WSL Remote.

The browser login completes, but the callback page shows:

Token exchange failed:
error sending request for url (https://auth.openai.com/oauth/token)

Running the bundled CLI directly produces the same result:

codex login

fails with:

error sending request for url (https://auth.openai.com/oauth/token)

and

codex login --device-auth

also fails with:

error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)

Additional troubleshooting

  • No proxy configured.
  • curl https://auth.openai.com/oauth/token succeeds (HTTP 405 as expected).
  • curl -4 also succeeds.
  • CA certificates are present.
  • System time is correct.
  • The bundled codex binary is statically linked.

This suggests the issue is specific to the Linux/WSL bundled Codex CLI rather than general network connectivity.

juanfernandezntt · 27 days ago

hi @etraut-openai , can you please add some update about this issue , thanks in advance

LinYeeGiong · 2 days ago

Codex Remote Login Troubleshooting

localhost Refused to Connect

After logging in, the browser may show:

localhost refused to connect

Codex is running on the remote server, but the OAuth callback uses localhost:1455. In VS Code Remote SSH, open the PORTS panel and forward remote port 1455 to the local machine. Then restart the Codex login process.

Token Exchange Failed

After port forwarding, Codex may show:

Token exchange failed: error sending request for url

This usually means the remote server cannot connect to the authentication service. Enable TUN mode for the proxy on both the local machine and the remote server, then restart the login process.

sunny2eastgo · 1 day ago

The issue is now resolved in my environment.

Previously, login failed with:

  • VS Code: 1.125.1
  • Bundled Codex CLI: 0.142.0-alpha.6

After updating, login succeeds with:

  • VS Code: 1.129.1
  • Bundled Codex CLI: 0.144.5

I did not change my WSL, proxy, network, CA certificate, or authentication settings.

Current environment:

  • Windows: 10.0.26200.8655
  • WSL: 2.7.8.0
  • Ubuntu: 24.04.4 LTS
  • Kernel: 6.18.33.1-1
  • VS Code Remote - WSL

So the issue may have been resolved by a recent VS Code, ChatGPT extension, or bundled Codex CLI update.