codex login didn't support ChatGPT SSO
What version of Codex is running?
codex-cli 0.47.0
What subscription do you have?
Business Plan
Which model were you using?
not related
What platform is your computer?
Darwin 25.0.0 arm64 arm
What issue are you seeing?
codex login didn't works as expected when "Enforce SSO log in" on ChatGPT account.
<img width="837" height="454" alt="Image" src="https://github.com/user-attachments/assets/fb737658-b0b3-4925-96d6-49f349ae1a20" />
What steps can reproduce the bug?
- Login to ChatGPT account where SSO is enabled and enforce
- Try run
codex exec "hello" - Got
exceeded retry limit, last status: 401 Unauthorized, request id: 99305b0bedfb45b1-BKK
<img width="2415" height="763" alt="Image" src="https://github.com/user-attachments/assets/b095360b-21cb-48e5-a507-70561622fa14" />
What is the expected behavior?
Able to login successfully and chat with codex.
Additional information
The workaround I found is...
- run
codexthen run/logout - run
codexagain and login when it prompt - this will works until exit codex tui
I did some investigating on token and found that the jwt token created on first login, contains sso_connection_id field as well as sub fields having saml format. HOWEVER, on subsequence token missing sso_connection_id and sub fields having auth0 instead.
On first login
<img width="675" height="958" alt="Image" src="https://github.com/user-attachments/assets/54fa9410-220e-47cc-8ba9-2518db03daab" />
On subsequence execute
<img width="662" height="908" alt="Image" src="https://github.com/user-attachments/assets/a6222a73-4dd2-4572-ac9c-c49dc472bda4" />
I also check network, and saw that openai return below error, when token missing sso_connection_id.
{
"detail": {
"code": "require_sso_login",
"account_name": "<account-name>"
}
}
8 Comments
Thank you for the report, we are looking into it!
Can you run
/feedbackafter getting a 401 error? That will share a bit more information that's helpful for debugging.I also have a problem with SSO, I use
codex login, it opens the home page, I put the company email, it redirects to Okta then shows this error.The Okta login works fine for the ChatGPT website but not for codex cli
<img width="652" height="566" alt="Image" src="https://github.com/user-attachments/assets/6cb7fdeb-9004-42bf-8544-0bea82ecee0b" />
@kamontat can you try deleting
~/.codex/auth.json, doing login and seeing whether it works across codex sessions?@pakrym-oai tried, several times, but no luck.
Here is the detailed steps with /feedback as you requested:
~/.codex/auth.jsonfilecodex, then login using oktacodexagainexceeded retry limit, last status: 401 Unauthorized, request id: ***I also notice that some time after first login, the token in auth.json got refreshed to invalid one (the one without sso_connection_id) even though the token is still valid.
I would love to help contributing and help fixes the issue.
@kamontat I'd love your help! Can you try to debug why the token refresh is triggered? See CodexAuth.refresh_token
@pakrym-oai I'm no longer able to reproduce the premature refresh token today, so I need to wait for token to expire. As my suspect is on refresh flow.
Closing old bugs.