You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Opencode not handling expired refresh_tokens #13998
The current implementation of the OAuth client does not gracefully handle an invalid_grant error response from the /token endpoint. When the authorization server returns a 400 Bad Request with error: "invalid_grant", the client remains in an unauthenticated state without triggering a new authorization flow.
From RFC 6749 § 5.2
invalid_grant
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked... The authorization server responds with an HTTP 400 (Bad Request)
Opencode does not handle this and remains in a error state, until users manually have to logout and auth again.
Instead, it should start a new authorization flow through the browser
Plugins
No response
OpenCode version
1.2.6
Steps to reproduce
Setup a MCP server with oauth that returns refresh_tokens that are valid for 5m, and access tokens valid for 1m.
Add this mcp server to opencode
opencode mcp auth and complete the initial authorization flow
wait 6 minutes
opencode mcp auth, server credentials show as expired. When saying OK to reauthenticate, it fails as the refresh token has expired.
Activity
github-actions commentedon Feb 17, 2026
This issue might be a duplicate of or related to existing issues. Please check:
Both issues involve the
opencode mcp authcommand failing during reauthentication scenarios.