What version of the Codex App are you using (From “About Codex” dialog)?
Codex 0.147.0
What subscription do you have?
ChatGPT Plus account
What platform is your computer?
No response
What issue are you seeing?
Codex 0.147.0: token_exchange_failed after successful browser authentication on Windows and WSL
Environment
- Windows 11 x64
- ChatGPT Plus account
- Codex CLI:
codex-cli 0.147.0
- Codex installed via npm on Windows
- Tested with Codex Desktop as well as Codex CLI
- Additionally tested with a fresh Codex installation inside WSL/Linux
Problem
Codex authentication cannot be completed.
The browser authentication itself succeeds. After signing in, the browser confirms that authentication was successful and says that the page can be closed.
However, Codex subsequently fails when exchanging the authorization code for a token:
Sign-in could not be completed
Token exchange failed: error sending request for url
(https://auth.openai.com/oauth/token)
Error code: token_exchange_failed
Details:
Token exchange failed: error sending request for url
(https://auth.openai.com/oauth/token)
This occurs both with Codex Desktop and the Codex CLI.
Device authentication also fails
I also tested:
codex login --device-auth
This fails with:
Error logging in with device code:
error sending request for url
(https://auth.openai.com/api/accounts/deviceauth/usercode)
Network tests
DNS resolution works:
nslookup auth.openai.com
Name: auth.openai.com.cdn.cloudflare.net
Addresses:
2a06:98c1:310c::ac40:920f
2606:4700:4400::6812:29f
104.18.41.241
172.64.146.15
Aliases: auth.openai.com
HTTPS connectivity to the authentication server also exists:
curl -I https://auth.openai.com
returns:
HTTP/1.1 403 Forbidden
Cf-Mitigated: challenge
Server: cloudflare
So the machine can reach auth.openai.com, but Cloudflare responds with a challenge to the curl request.
Proxy tests
Windows WinHTTP configuration:
netsh winhttp show proxy
DirectAccess (no proxy server)
No proxy environment variables are present:
returns no output.
Different network tested
To rule out the router, ISP connection, or public IP address, I disconnected the PC from the normal network and connected it through a mobile phone hotspot.
The Codex authentication failure remained exactly the same.
Therefore, the problem does not appear to be specific to the normal internet connection, router, or public IP.
WSL/Linux test
To rule out a problem specific to the native Windows Codex runtime, I installed WSL and a Linux environment.
Node.js/npm and Codex were installed natively inside WSL.
The Linux Codex installation was verified:
which codex
/usr/local/bin/codex
codex --version
codex-cli 0.147.0
I then ran:
The browser opened and authentication completed successfully. The browser explicitly indicated that the login was successful and that the page could now be closed.
After closing the browser page, however, Codex did not complete the login successfully.
The token exchange failed again.
Thus, the problem can be reproduced with:
- Codex Desktop on Windows
- Codex CLI on Windows
- Codex CLI running natively inside WSL/Linux
- normal internet connection
- separate mobile hotspot
Additional symptom
Before investigating the authentication problem, Codex had also repeatedly produced connection errors similar to:
stream disconnected before completion:
error sending request for url
(https://chatgpt.com/backend-api/codex/responses)
It is unclear whether this is related, but it may indicate a more general connectivity problem between the Codex client and OpenAI endpoints.
At approximately the same time, the normal ChatGPT browser session unexpectedly required a new login. The ChatGPT browser login itself succeeded.
Summary
Browser authentication works, but Codex cannot complete the subsequent communication with OpenAI's authentication endpoints.
The issue persists after ruling out:
- DNS resolution
- normal internet connection
- router
- public IP (tested via mobile hotspot)
- WinHTTP proxy
- proxy environment variables
- native Windows Codex runtime
- alternative device authentication
- Codex running inside WSL/Linux
The most notable observation is that the browser reports a successful Codex authentication, but the subsequent token exchange performed by Codex fails.
Please advise whether this could be related to the current Codex authentication/token exchange implementation, Cloudflare handling, or an account/session-side issue.
What steps can reproduce the bug?
I cant use codex or Chatgpt localy
What is the expected behavior?
It works until this afternoon - suddenly the connection was frozen
Additional information
No response
What version of the Codex App are you using (From “About Codex” dialog)?
Codex 0.147.0
What subscription do you have?
ChatGPT Plus account
What platform is your computer?
No response
What issue are you seeing?
Codex 0.147.0:
token_exchange_failedafter successful browser authentication on Windows and WSLEnvironment
codex-cli 0.147.0Problem
Codex authentication cannot be completed.
The browser authentication itself succeeds. After signing in, the browser confirms that authentication was successful and says that the page can be closed.
However, Codex subsequently fails when exchanging the authorization code for a token:
This occurs both with Codex Desktop and the Codex CLI.
Device authentication also fails
I also tested:
This fails with:
Network tests
DNS resolution works:
HTTPS connectivity to the authentication server also exists:
returns:
So the machine can reach
auth.openai.com, but Cloudflare responds with a challenge to the curl request.Proxy tests
Windows WinHTTP configuration:
No proxy environment variables are present:
returns no output.
Different network tested
To rule out the router, ISP connection, or public IP address, I disconnected the PC from the normal network and connected it through a mobile phone hotspot.
The Codex authentication failure remained exactly the same.
Therefore, the problem does not appear to be specific to the normal internet connection, router, or public IP.
WSL/Linux test
To rule out a problem specific to the native Windows Codex runtime, I installed WSL and a Linux environment.
Node.js/npm and Codex were installed natively inside WSL.
The Linux Codex installation was verified:
I then ran:
The browser opened and authentication completed successfully. The browser explicitly indicated that the login was successful and that the page could now be closed.
After closing the browser page, however, Codex did not complete the login successfully.
The token exchange failed again.
Thus, the problem can be reproduced with:
Additional symptom
Before investigating the authentication problem, Codex had also repeatedly produced connection errors similar to:
It is unclear whether this is related, but it may indicate a more general connectivity problem between the Codex client and OpenAI endpoints.
At approximately the same time, the normal ChatGPT browser session unexpectedly required a new login. The ChatGPT browser login itself succeeded.
Summary
Browser authentication works, but Codex cannot complete the subsequent communication with OpenAI's authentication endpoints.
The issue persists after ruling out:
The most notable observation is that the browser reports a successful Codex authentication, but the subsequent token exchange performed by Codex fails.
Please advise whether this could be related to the current Codex authentication/token exchange implementation, Cloudflare handling, or an account/session-side issue.
What steps can reproduce the bug?
I cant use codex or Chatgpt localy
What is the expected behavior?
It works until this afternoon - suddenly the connection was frozen
Additional information
No response