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_
11 Comments
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
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
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 -->
same for here.... any idea?
same for my MacBook.
can any add some info? thanks
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.
I can reproduce the same issue, but only when running the ChatGPT extension inside WSL Remote.
Environment
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:
Running the bundled CLI directly produces the same result:
fails with:
and
also fails with:
Additional troubleshooting
curl https://auth.openai.com/oauth/tokensucceeds (HTTP 405 as expected).curl -4also succeeds.codexbinary is statically linked.This suggests the issue is specific to the Linux/WSL bundled Codex CLI rather than general network connectivity.
hi @etraut-openai , can you please add some update about this issue , thanks in advance
Codex Remote Login Troubleshooting
localhostRefused to ConnectAfter logging in, the browser may show:
localhost refused to connectCodex 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 port1455to 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 urlThis 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.
The issue is now resolved in my environment.
Previously, login failed with:
After updating, login succeeds with:
I did not change my WSL, proxy, network, CA certificate, or authentication settings.
Current environment:
So the issue may have been resolved by a recent VS Code, ChatGPT extension, or bundled Codex CLI update.