-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Open
Description
Summary
Add support for multiple OAuth accounts per provider with automatic credential rotation and browser-based session management for expired tokens.
Motivation
Currently, OpenCode only supports a single OAuth account per provider. When that account hits rate limits, work stops. Users who have multiple accounts (e.g. personal + work) need to manually switch between them.
This feature enables:
- Multiple accounts per provider — add as many OAuth accounts as you want
- Automatic failover — when one account hits rate limits or auth failures, seamlessly rotate to the next
- Browser-based auto-relogin — automatically refresh expired tokens using Puppeteer sessions
- Per-request credential tracking — know which account is being used for each session
Changes
Backend (packages/opencode)
- Multi-account store: Track multiple OAuth records per provider in
auth/index.ts - Credential rotation (
auth/rotating-fetch.ts): Automatically failover to next account on rate limits or auth failures - Browser sessions (
auth/browser.ts): Puppeteer-based auto-relogin for expired tokens - Credential manager (
auth/credential-manager.ts): Event-driven failover notifications - Auth context (
auth/context.ts): AsyncLocalStorage for per-request credential tracking - Config:
oauthrotation settings (cooldowns, retries, max attempts) - CLI: Browser session management commands
- Server routes: Account CRUD, usage, browser session endpoints
Frontend (packages/app)
- Provider settings: Manage accounts, set active, view usage
- Session context tab: Show which account is active per session
SDK
- Regenerated with all new multi-account endpoints
Related
Split from #9971 (closed) for cleaner review.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels