codex icon indicating copy to clipboard operation
codex copied to clipboard

The codex cli giving: 401 unauthorized

Open isha-paliwal3 opened this issue 10 months ago • 16 comments

What version of Codex is running?

codex-cli 0.80.0

What subscription do you have?

chatgpt Plus

Which model were you using?

gpt-5.2 medium

What platform is your computer?

Windows

What issue are you seeing?

Image Image

What steps can reproduce the bug?

Uploaded thread: 019bb81c-f4d0-7992

What is the expected behavior?

Should return a proper response

Additional information

No response

isha-paliwal3 avatar Jan 13 '26 16:01 isha-paliwal3

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

  • #8807
  • #8703
  • #7918
  • #7362
  • #7107

Powered by Codex Action

github-actions[bot] avatar Jan 13 '26 16:01 github-actions[bot]

It looks like you've logged out and logged back in. Is that correct? You could try deleting the auth.json file manually and then log in again, but that's unlikely to fix it.

What type of ChatGPT plan do you have? Is it a Plus subscription?

etraut-openai avatar Jan 13 '26 18:01 etraut-openai

It looks like you've logged out and logged back in. Is that correct? You could try deleting the auth.json file manually and then log in again, but that's unlikely to fix it.

What type of ChatGPT plan do you have? Is it a Plus subscription?

Hi @etraut-openai, yes I have a plus subscription, And I tried deleting the auth.json as well but it did not fix it

isha-paliwal3 avatar Jan 14 '26 06:01 isha-paliwal3

This must be something specific to your account. Could I get your user ID? You can find it by going to https://chatgpt.com/codex, clicking on the upper right icon to show the profile menu and then clicking on your email address (top menu item). This will put your user ID on the clipboard so you can paste it here. It will be of the form "user-".

etraut-openai avatar Jan 14 '26 06:01 etraut-openai

I am also experiecing the same problem. user-JpFWYFj65MQ76y39JSuMrua9

alphaai avatar Jan 14 '26 11:01 alphaai

@etraut-openai here is my user Id can you pls check?

user-SiimSO1vjX7pcbW1JqTimawk

isha-paliwal3 avatar Jan 15 '26 18:01 isha-paliwal3

also having same issue.

  1. on Teams plan with SAML setup to Google Workspace
  2. Can log-in and use chatGPT
  3. get 401 after logging into codex

peterjliu avatar Jan 19 '26 22:01 peterjliu

By any chance, are all of you who are experiencing the 401 error using the "log in with Google" option? Are any of you using an OpenAI account password to log in?

etraut-openai avatar Jan 19 '26 23:01 etraut-openai

Yes using Google to log-in or passkey. Over the past few months I observed multiple issues with SSO and chatGPT (e.g. https://github.com/openai/codex/issues/3782#issuecomment-3311165906, https://github.com/openai/codex/issues/5553). I think you should take a look at this seriously.

peterjliu avatar Jan 20 '26 06:01 peterjliu

I have this same issue. On pro plan. Using OpenAI account password to log in. Originally had collision with port 1455 but killed that port and it allowed me to log in. But still got 401 error after that. Also tried deleting auth.json and re-logging in. Still 401 error. Oddly, this authentication issue does not affect the codex app/extension in VSCode/Cursor etc.

voxmenthe avatar Jan 20 '26 17:01 voxmenthe

@voxmenthe, if you're able to repro the problem, please use the /feedback slash command to upload your logs and post the thread ID here. Are you using any firewalls, VPNs, proxies or other special network configurations?

etraut-openai avatar Jan 20 '26 23:01 etraut-openai

@voxmenthe, if you're able to repro the problem, please use the /feedback slash command to upload your logs and post the thread ID here. Are you using any firewalls, VPNs, proxies or other special network configurations?

I am able to repro it - did the feedback thread ID 019bde1b-34a7-7c72-90da-c4cfdd31a024 Additional context is that the issue seems limited to a particular repo.

voxmenthe avatar Jan 21 '26 01:01 voxmenthe

@voxmenthe, thanks for uploading your logs. It looks like you're using the endpoint https://api.z.ai/api/coding/paas/v4/responses. Given the symptom you're seeing (an error that's specific to a particular repo), I'm guessing that the error is coming from this endpoint rather than OpenAI. Are you able to repro the problem if you use the standard OpenAI endpoint?

etraut-openai avatar Jan 22 '26 02:01 etraut-openai

Yeah thanks I had just figured that out. unset OPENAI_BASE_URL and works

voxmenthe avatar Jan 22 '26 03:01 voxmenthe

hi @etraut-openai can you look into my repro, thread id 019be460-d2b8-7b13-b17a-2a3334ea74d6

peterjliu avatar Jan 22 '26 06:01 peterjliu

Yeah thanks I had just figured that out. unset OPENAI_BASE_URL and works

Yes! That worked for me too! Perhaps a tool like this should use a more obscure env var name so people don't accidentally override it?

joelcma avatar Jan 26 '26 07:01 joelcma