0.149.0: Auth headers not sent — 401 Unauthorized in ChatGPT login mode (worked in 0.148.0)
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
- 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)
- 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
- Token is valid (JWT exp ~10 days out, refreshed today), plan = Pro.
- Colleagues on the same shared machine and same network egress run older versions without issues.
- Downgrade to 0.148.0 (no other changes) → everything works again.
What steps can reproduce the bug?
Repro
npm i -g @openai/codex@0.149.0codex login(ChatGPT mode)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_
3 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
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.