Windows Desktop loses access token and returns to login after /accounts/{account_id}/settings 401
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What version of the Codex App are you using (From “About Codex” dialog)?
26.818.5345.0
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What issue are you seeing?
The Codex Desktop app on Windows successfully signs in with my ChatGPT account and initially works normally.
However, as soon as I open an existing conversation or send a new prompt, the app returns to the ChatGPT login screen within a few seconds.
This does not appear to be a normal application crash. The ChatGPT/Codex processes remain running. Instead, the Desktop authentication state changes from authenticated to unauthenticated.
The issue is highly reproducible.
The Desktop logs show the following sequence:
1. The account is initially authenticated successfully:
[chatgpt-account-lookup] completed
authenticatedAccountPresent=true
authMethod=chatgpt
result=succeeded
2. A few seconds later, the Desktop sends:
GET https://chatgpt.com/backend-api/accounts/:param/settings
and receives HTTP 401 even though a token is present:
desktop_fetch_auth_401
hadToken=true
tokenSource=cached
willRetry=true
3. Immediately afterwards, the authentication state changes to:
app_server_connection.auth_status_result
authMethod=chatgpt
hasToken=false
nullReason=auth_token_missing
refreshToken=true
tokenExpiryState=missing
4. Account lookup then fails:
[chatgpt-account-lookup] completed
authenticatedAccountPresent=false
authMethod=chatgpt
failureType=account_info_token_unavailable
result=failed
5. The account settings request reports:
Missing valid access token or actor biscuit
status=401
routePattern=/accounts/{account_id}/settings
6. Subsequent requests fail with:
desktop_fetch_auth_401
hadToken=false
skipRetryReason=no_token_attached
and:
Unauthorized - Access token is missing
The UI then returns to the ChatGPT login screen.
The same sequence has reproduced multiple times.
ChatGPT Web continues to work normally with the same account.
Codex CLI also remains logged in:
codex login status
→ Logged in using ChatGPT
I also tested a real CLI model request:
codex exec --skip-git-repo-check "Reply with exactly: CODEX_AUTH_OK"
The WebSocket transport initially receives HTTP 403, but Codex CLI falls back to HTTPS and successfully completes the request:
CODEX_AUTH_OK
Therefore, the ChatGPT account itself is still valid and authenticated. The failure appears specific to the Windows Desktop authentication/token state.
What steps can reproduce the bug?
-
Launch Codex Desktop on Windows.
-
Sign in successfully using a ChatGPT account.
-
Wait until the Codex Desktop home screen loads normally.
-
Open any existing conversation.
Alternatively, start a new conversation and send any prompt.
-
Within a few seconds, Codex Desktop returns to the ChatGPT login screen.
-
Sign in again.
-
Open a conversation or send another prompt.
-
The app returns to the login screen again.
The issue is highly reproducible.
I reproduced it multiple times and observed the same authentication sequence in the Desktop logs:
authenticatedAccountPresent=true
→ /accounts/{account_id}/settings returns HTTP 401 with hadToken=true
→ hasToken=false
→ nullReason=auth_token_missing
→ refreshToken=true
→ authenticatedAccountPresent=false
→ failureType=account_info_token_unavailable
→ Desktop returns to login screen
No special prompt is required. Simply opening an existing conversation is sufficient to reproduce the issue.
What is the expected behavior?
After successfully signing in, Codex Desktop should remain authenticated.
Opening an existing conversation or sending a new prompt should not invalidate or remove the Desktop access token.
If an authenticated request temporarily returns HTTP 401, the Desktop app should refresh or recover the authentication state when a valid refresh token is still available instead of changing the account state to unauthenticated and returning the user to the login screen.
Additional information
Additional observations:
- Codex Desktop version: 26.818.5345.0
- Codex CLI version: 0.149.0
- Authentication method: ChatGPT
- ChatGPT Plus account
- Advanced Account Security is NOT enabled
- ChatGPT Web works normally with the same account
- Codex CLI remains logged in
- Codex CLI can successfully complete an authenticated model request over HTTPS
- Reinstalling / resetting the Windows Desktop app did not resolve the issue
- Rebuilding the Desktop profile did not resolve the issue
- The behavior does not appear to be a conventional ChatGPT.exe process crash
The most suspicious transition is:
authenticatedAccountPresent=true
↓
GET /backend-api/accounts/{account_id}/settings
HTTP 401
hadToken=true
↓
hasToken=false
nullReason=auth_token_missing
refreshToken=true
↓
authenticatedAccountPresent=false
failureType=account_info_token_unavailable
↓
Desktop returns to login screen
This looks like a Windows Desktop authentication/token-state regression.
After /accounts/{account_id}/settings returns HTTP 401, the Desktop appears to lose the current access token. Although refreshToken=true is still reported, the access token is not successfully recovered or re-attached before the account is marked unauthenticated.
I have redacted the real account ID and other identifying information from the logs.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by tracing Windows Desktop authentication handling around GET /backend-api/accounts/{account_id}/settings and the log markers desktop_fetch_auth_401, auth_status_result, and chatgpt-account-lookup. Reproduce the 401 sequence and verify that a valid refresh path preserves authentication instead of returning the user to login.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- authentication, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100