openai / openai/codex

Codex Desktop login loop on macOS while CLI works; auth refresh drops token after 401

Open
#39,718 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app auth bug
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Summary

Codex CLI works normally with ChatGPT authentication, but Codex Desktop on macOS enters a login loop whenever I open/select a conversation.

The Desktop app initially detects the authenticated ChatGPT account successfully. However, when a conversation is opened, a backend request returns HTTP 401. The Desktop then attempts to refresh authentication, but the auth state changes to:

authMethod=chatgpt
hasToken=false
nullReason=auth_token_missing
refreshToken=true
tokenExpiryState=missing

After that, subsequent requests are sent without an access token and return 401, causing the Desktop app to ask me to log in again.

Relevant logs

desktop_fetch_auth_401 hadToken=true ... willRetry=true

app_server_connection.auth_status_result
authMethod=chatgpt
hasToken=false
nullReason=auth_token_missing
refreshToken=true
tokenExpiryState=missing

chatgpt-account-lookup
authenticatedAccountPresent=false
failureType=account_info_token_unavailable

Missing valid access token or actor biscuit

desktop_fetch_auth_401
hadToken=false
skipRetryReason=no_token_attached

Earlier in the same run, the Desktop app successfully detected the authenticated account:

chatgpt-account-lookup ... authenticatedAccountPresent=true authMethod=chatgpt ... result=succeeded

The failure then occurs when opening/selecting a conversation.

Expected behavior

Codex Desktop should reuse or successfully refresh the valid ChatGPT authentication state, as Codex CLI does.

Actual behavior

Desktop starts normally and initially recognizes the authenticated account, but opening/selecting a conversation causes authentication to fail and the app asks me to log in again.

Troubleshooting already performed

  • Upgraded Codex CLI from an older version; CLI now works normally
  • Verified codex login status reports ChatGPT authentication
  • Verified ~/.codex/auth.json exists and has correct permissions
  • Reset Codex Desktop Application Support and cache
  • Reinstalled/updated Codex Desktop
  • Verified CODEX_HOME is not overridden
  • Verified no CODEX_ACCESS_TOKEN, OPENAI_API_KEY, OPENAI_BASE_URL, or related environment overrides exist
  • Issue still reproduces with a clean Desktop profile while CLI continues to work

Environment

  • macOS
  • ChatGPT authentication
  • Codex CLI: working normally
  • Codex Desktop: login loop when opening/selecting a conversation

Failure sequence

Desktop starts
  -> authenticated account is detected
  -> open/select a conversation
  -> request sent with token (`hadToken=true`)
  -> backend responds 401
  -> Desktop attempts refresh
  -> auth becomes `hasToken=false`, `auth_token_missing`, `refreshToken=true`
  -> subsequent requests are sent without a token
  -> login prompt appears again

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the desktop_fetch_auth_401 flow and app_server_connection.auth_status_result logs, then compare the Desktop refresh path with the working Codex CLI authentication state. Reproduce by opening or selecting a conversation and trace the transition from hadToken=true to auth_token_missing. Done means Desktop retains or successfully refreshes the token and no longer enters the login loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.