Skip to content

Claude OAuth token requires re-authentication after every usage limit reset #15562

Closed as not planned

Description

@coskunhasib

Description

Describe the bug
When using Claude via OAuth (claude.ai subscription), opencode requires me to re-authenticate every time a usage limit resets. Claude.ai has two types of limits:

A 5-hour rolling limit (resets every ~5 hours)
A monthly quota

Both trigger a full re-authentication flow in opencode. This means I may need to re-login multiple times per day.
Expected behavior
OAuth tokens should be refreshed automatically using the refresh token. Re-authentication should only be required when the user explicitly logs out or when the token is truly invalidated — not on usage limit resets.
Actual behavior
After hitting either the 5-hour or monthly usage limit, opencode throws an authentication error and requires a full re-login via opencode auth login.
Why this matters
Users on Claude.ai subscription plans (Pro/Max) cannot use API keys — OAuth is their only option. Other providers do not have this issue. This is likely caused by opencode treating a 429 rate-limited or quota-exceeded response as an auth failure, and/or not properly storing/using the OAuth refresh token.
Steps to reproduce

Log in with opencode auth login using Claude OAuth
Use opencode until Claude.ai usage limit is hit (can happen within 5 hours)
Wait for the limit to reset
Try to use opencode again → re-authentication required

Environment

Provider: Claude (claude.ai OAuth)
Subscription: Claude Pro/Max (not API key)

Plugins

No response

OpenCode version

1.2.15

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Mar 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is the same as one of the above, please add a comment there instead so the discussion stays in one place.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 1, 2026
  3. coskunhasib commented on Mar 1, 2026

    @coskunhasib
    Author

    win11 pro 25H2 26200.7840
    opencode dektop app

  4. MoerAI commented on Mar 20, 2026

    @MoerAI

    Related fix for the token exchange 429 issue that causes forced re-authentication:

    The opencode-anthropic-auth plugin was missing the User-Agent header and using wrong Content-Type for OAuth token requests. This causes Anthropic's token endpoint to return 429, which OpenCode interprets as an auth failure requiring full re-login.

    PR: ex-machina-co/opencode-anthropic-auth#12

    See detailed analysis at #18329 (comment)

  5. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions