Skip to content

codex login didn't support ChatGPT SSO #5553

Closed

Description

@kamontat

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.

Image

What steps can reproduce the bug?

  1. Login to ChatGPT account where SSO is enabled and enforce
  2. Try run codex exec "hello"
  3. Got exceeded retry limit, last status: 401 Unauthorized, request id: 99305b0bedfb45b1-BKK
Image

What is the expected behavior?

Able to login successfully and chat with codex.

Additional information

The workaround I found is...

  1. run codex then run /logout
  2. run codex again and login when it prompt
  3. 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

Image

On subsequence execute

Image

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>"
  }
}

Activity

  1. pakrym-oai commented on Oct 23, 2025

    @pakrym-oai
    Contributor

    Thank you for the report, we are looking into it!

  2. pakrym-oai commented on Oct 23, 2025

    @pakrym-oai
    Contributor

    Can you run /feedback after getting a 401 error? That will share a bit more information that's helpful for debugging.

  3. melsharnou-chwy commented on Oct 23, 2025

    @melsharnou-chwy

    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

    An error occurred during authentication. Please try again.
    You can contact us through our help center at [help.openai.com](https://help.openai.com/) if you keep seeing this error. (Please include the request ID bc190af84420a4b63c32d4120952c03d in your email.)
    
    Image
  4. pakrym-oai commented on Oct 24, 2025

    @pakrym-oai
    Contributor

    @kamontat can you try deleting ~/.codex/auth.json, doing login and seeing whether it works across codex sessions?

  5. kamontat commented on Oct 24, 2025

    @kamontat
    Author

    @pakrym-oai tried, several times, but no luck.

    Here is the detailed steps with /feedback as you requested:

    1. Delete ~/.codex/auth.json file
    2. Run codex, then login using okta
    3. enter prompt hello
    4. run /feedback
    5. Thread ID: 019a167c-9f53-7960-9f75-e36cfcc449ee
    6. THEN... exit codex tui
    7. run codex again
    8. enter prompt hello
    9. GOT exceeded retry limit, last status: 401 Unauthorized, request id: ***
    10. Thread ID: 019a167d-bf89-7e03-b035-89a0209ee37e

    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.

  6. pakrym-oai commented on Oct 24, 2025

    @pakrym-oai
    Contributor

    @kamontat I'd love your help! Can you try to debug why the token refresh is triggered? See CodexAuth.refresh_token

  7. kamontat commented on Oct 25, 2025

    @kamontat
    Author

    @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.

  8. added
    authIssues related to authentication and accounts
    on Nov 2, 2025
  9. etraut-openai commented on Jan 10, 2026

    @etraut-openai
    Contributor

    Closing old bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues related to authentication and accountsbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions