Skip to content

OAuth tokens too long for Windows keyring #10353

Closed

Description

@ofek

What version of Codex is running?

0.93.0

What subscription do you have?

Plus

Which model were you using?

No response

What platform is your computer?

Windows 11

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

Windows Terminal

What issue are you seeing?

The primary login mechanism via OAuth doesn't work on Windows when using the keyring storage option.

Unable to persist auth file: failed to write OAuth tokens to keyring: Attribute 'password encoded as UTF-16' is longer than platform limit of 2560 chars
Image

What steps can reproduce the bug?

Log in with the following configuration:

cli_auth_credentials_store = "keyring"
mcp_oauth_credentials_store = "keyring"

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    bugSomething isn't working
    on Feb 2, 2026
  2. added
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    authIssues related to authentication and accounts
    on Feb 2, 2026
  3. etraut-openai commented on Feb 2, 2026

    @etraut-openai
    Contributor

    Thanks for reporting. The keyring feature isn't supported on Windows currently. I'm going to change this from a bug report to a feature request. In the meantime, I'll make it clearer in our documentation, and we'll work on getting a better error message in place.

  4. changed the title [-]OAuth tokens too long for Windows keyring[/-] [+]Support keyring auth storage on Windows[/+] on Feb 2, 2026
  5. added
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    on Feb 2, 2026
  6. etraut-openai commented on Feb 2, 2026

    @etraut-openai
    Contributor

    Oh, I take that back. I just heard back from the Codex team member who implemented the keyring support, and she confirmed that this should work on Windows. So it sounds like this is a bug. She'll investigate.

  7. added
    bugSomething isn't working
    and removed
    enhancementNew feature or request
    on Feb 2, 2026
  8. changed the title [-]Support keyring auth storage on Windows[/-] [+]OAuth tokens too long for Windows keyring[/-] [+]Support keyring auth storage on Windows[/+] on Feb 2, 2026
  9. changed the title [-]OAuth tokens too long for Windows keyring[/-] [+]Support keyring auth storage on Windows[/-] [+]OAuth tokens too long for Windows keyring[/+] on Feb 2, 2026
  10. self-assigned this
    on Feb 2, 2026
  11. Ashutosh0x commented on Feb 4, 2026

    @Ashutosh0x
    Contributor

    Hi @celia-oai @etraut-openai, I'm a developer interested in contributing! I saw this report about OAuth tokens exceeding the 2560-character limit in Windows Credential Manager. Since I'm on Windows, I'd like to work on a fix involving token chunking for the keyring store. Does that approach sound good to you?

  12. added a commit that references this issue on Feb 4, 2026
    af7ac9f
  13. Ashutosh0x commented on Feb 4, 2026

    @Ashutosh0x
    Contributor

    Hey! I've been looking into the TooLong errors on Windows and wanted to share the root cause and a potential path forward.

    Root Cause

    On Windows, the Credential Manager (which the keyring crate uses) has a hard limit on the length of the secret (the "password" field). This limit is roughly 2560 bytes (which equates to 1280 UTF-16 characters).

    As OAuth tokens grow (especially with larger JWT payloads or session data), they are hitting this system-level constraint, leading to the TooLong error during login.

    Proposed Fix: Token Chunking

    The most reliable way to handle this without changing the storage backend is to implement transparent chunking in the keyring-store.

    When a value exceeds a safe threshold (e.g., 2048 bytes):

    1. Split the value into multiple chunks.
    2. Store a "manifest" in the primary key with a header (e.g., CODEX_CHUNKED:N:<checksum>) where N is the number of chunks.
    3. Store the actual data chunks in auxiliary keys (e.g., account:1, account:2, ...).

    Implementation Logic

    1. Write Path: Detect length. If too long, calculate chunks. Store chunks first, then store the manifest key.
    2. Read Path: Check for the CODEX_CHUNKED header. If present, load all auxiliary keys, verify integrity (e.g., via checksum or just length), and reassemble.
    3. Delete Path: Ensure that auxiliary keys are cleaned up when the primary key is deleted.

    Verification

    I've tested this logic locally with tokens up to 10,000 characters. It successfully bypasses the Windows Credential Manager limits while maintaining compatibility with the existing keyring API used by Codex.


    I had a draft implementation ready, but since the guidelines are now invitation-only, I'm sharing the analysis here first. Happy to help more if the team wants to pursue this approach!

  14. added 3 commits that reference this issue on Feb 5, 2026
    ba8222f
    b7f069f
    616a94e
  15. Ashutosh0x commented on Feb 11, 2026

    @Ashutosh0x
    Contributor

    Following up on the discussion in PR #10732, I'm moving the technical analysis for the proposed fix for this issue here as requested by @etraut-openai.

    Technical Analysis for #10353

    What?
    Implement transparent token chunking for the Windows keyring to bypass the hard 2560-byte limit of the Windows Credential Manager.

    Why?
    Modern OAuth tokens often exceed the Windows limit. Without chunking, authentication fails silently for Windows users, creating a major platform disparity.

    How?

    • Chunking Mechanism: Splits tokens into 1024-char chunks stored as multi-part credentials (e.g., token, token:1).
    • Transparent Reconstruction: Uses a CODEX_CHUNKED: header to automatically reconstruct the full token during load operations.
    • Comprehensive Logic: Handles load, save, and delete operations to ensure orphaned chunks are correctly cleaned up.

    I have verified this implementation with tokens up to 5000 chars on Windows 11. If this fits the team's intended approach for solving this, I'd value an invitation to move this forward.

  16. celia-oai commented on Jun 12, 2026

    @celia-oai
    Contributor

    this is closed by the PR stack ending in #27541.

  17. ofek commented on Jun 12, 2026

    @ofek
    Author

    Thank you!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions