openai / openai/codex

[macOS] Refresh token is revoked after successful ChatGPT login, causing 401 in Desktop and CLI

Open
#41,973 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app auth bug CLI
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)?

Codex CLI 0.152.0

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

Codex authentication is failing on my Mac even though signing in with ChatGPT succeeds.

Both Codex Desktop and Codex CLI return:

unexpected status 401 Unauthorized: {"detail":"Unauthorized"}, url: https://chatgpt.com/backend-api/codex/responses

I also previously received the following message in Codex Desktop:

Your access token could not be refreshed because your refresh token was revoked. Please log out and sign in again.

Environment:

  • macOS
  • ChatGPT Plus
  • Codex CLI 0.152.0
  • Authentication method: ChatGPT
  • ChatGPT web works normally
  • Codex Desktop fails with 401
  • Codex CLI fails with 401

I confirmed that Codex is logged into the correct ChatGPT Plus account.

I have already tried:

  1. codex logout and signing in again
  2. codex login --device-auth
  3. Removing/renaming ~/.codex/auth.json and performing a fresh login
  4. Upgrading Codex CLI from 0.144.6 to 0.152.0
  5. Confirming that only one ChatGPT account is logged into the browser
  6. Testing both Codex Desktop and Codex CLI

Device-code authentication completes successfully, and:

codex login status

reports:

Logged in using ChatGPT

However, immediately after starting Codex and sending a simple prompt such as hello, the request to /backend-api/codex/responses returns 401 Unauthorized.

Expected behavior:

After a successful ChatGPT authentication, Codex Desktop and CLI should be able to send requests normally.

Actual behavior:

Authentication appears successful locally, but requests to the Codex backend are rejected with 401 Unauthorized. In some cases Codex reports that the refresh token has been revoked.

This appears similar to other recent refresh-token invalidation/authentication issues reported for Codex on macOS.

What steps can reproduce the bug?
  1. Sign in to Codex using a ChatGPT Plus account.
  2. Confirm codex login status shows Logged in using ChatGPT.
  3. Start Codex Desktop or run codex in the terminal.
  4. Send a simple prompt such as hello.
  5. Codex attempts to connect to https://chatgpt.com/backend-api/codex/responses.
  6. The request fails with 401 Unauthorized.
What is the expected behavior?

Codex should accept the authenticated ChatGPT session and respond to prompts normally.

Additional information

■ unexpected status 401 Unauthorized: {"detail":"Unauthorized"}, url: https://chatgpt.com/backend-api/codex/responses,
cf-ray: a34164fe1fa7df0a-SJC, request id: 40d8632f-c671-45d7-b6dc-e26d967e9d9b

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

Reproduce the failure with codex login --device-auth, codex login status, and a simple hello prompt in Codex Desktop or CLI, observing the request to /backend-api/codex/responses. Trace the ChatGPT refresh-token handling involved in the 401 and revoked-token messages; done means successful macOS login allows requests from both clients without authentication errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
api, authentication, cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.