Skip to content

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

@coskunhasib

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions