0.149.0: Auth headers not sent — 401 Unauthorized in ChatGPT login mode (worked in 0.148.0)

Resolved 💬 3 comments Opened Aug 21, 2026 by kailiangshang Closed Aug 22, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

0.149.0

What subscription do you have?

pro

Which model were you using?

_No response_

What platform is your computer?

linux

What terminal emulator and version are you using (if applicable)?

_No response_

Codex doctor report

What issue are you seeing?

Body:

Summary

After upgrading codex-cli from 0.148.0 to 0.149.0, all requests fail with 401 Unauthorized when using ChatGPT login auth. Downgrading to 0.148.0 with the exact same auth.json, config, and network immediately fixes it. Evidence suggests 0.149.0 does not attach auth headers to requests.

Environment

  • codex-cli 0.149.0 (installed via npm, linux-x64)
  • Auth mode: ChatGPT login (codex login status → "Logged in using ChatGPT")
  • Config: model_provider = "codex", wire_api = "responses" (default built-in provider)

Symptom 1: ChatGPT backend returns 401

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

Retries 5 times (also refreshes token via auth.openai.com in between) and fails.

Symptom 2: with CODEX_API_KEY set, no Authorization header at all

With CODEX_API_KEY exported, 0.149.0 routes requests to api.openai.com but the server responds:

401 Unauthorized: Missing bearer or basic authentication in header

i.e. no Authorization header was sent. On 0.148.0 with the same env var, the key IS sent (server returns invalid_api_key for my third-party relay key instead, proving the header exists in 0.148.0).

Evidence this is a client-side regression, not account/network

  1. Direct curl with the same access token from the same machine/network passes auth:

``bash
curl -X POST https://chatgpt.com/backend-api/codex/responses \
-H "Authorization: Bearer <access_token from auth.json>" \
-H "chatgpt-account-id: <account_id>" \
-d '{"model":"gpt-5.6-sol","input":[...]}'
# → HTTP 400 {"detail":"Store must be set to false"} (auth OK, request-shape complaint)
``

  1. Control test — omitting the Authorization header entirely reproduces the exact error:

``bash
curl -X POST https://chatgpt.com/backend-api/codex/responses -d '{...}'
# → HTTP 401 {"detail":"Unauthorized"} ← identical to codex 0.149.0's error
``

  1. Token is valid (JWT exp ~10 days out, refreshed today), plan = Pro.
  2. Colleagues on the same shared machine and same network egress run older versions without issues.
  3. Downgrade to 0.148.0 (no other changes) → everything works again.

What steps can reproduce the bug?

Repro

  1. npm i -g @openai/codex@0.149.0
  2. codex login (ChatGPT mode)
  3. codex exec "say OK" → 401 {"detail":"Unauthorized"} from chatgpt.com/backend-api/codex/responses

Possibly relevant debug-log fields observed in 0.149.0: auth_credentials_store_mode: File, keyring_backend_kind: Direct, enable_codex_api_key_env: true.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 7 days ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #39857
  • #39820

Powered by Codex Action

Grallen · 5 days ago

This report is thorough. I am just posting the command to downgrade for those that wander by: npm install -g @openai/codex@0.148.0

kailiangshang · 5 days ago
This report is thorough. I am just posting the command to downgrade for those that wander by: npm install -g @openai/codex@0.148.0

@Grallen Thanks for sharing the workaround!
Since this issue describes the same "401 Unauthorized / missing API key" problem caused by the 0.149.0 update as reported in #39857 and #39820, I'm going to close this as a duplicate. We can track the progress and wait for the official patch in those threads.