README · Setup · Troubleshooting · Architecture
| Method | Best for | Needs Claude Code | Auto refresh | Refresh mechanism |
|---|---|---|---|---|
| Claude Code session | Claude Code users | ✅ Yes | ✅ Best path | Triggers claude CLI |
| Browser sign-in | No Claude Code install | ❌ No | ✅ Yes | Anthropic OAuth refresh tokens |
| API key | Simple static auth | ❌ No | ❌ No | N/A |
Best for: users who already use Claude Code.
claudeCLI installed (claude.ai/download)- A valid Claude Code session (
claude auth login --claudeai)
- Plugin reads local Claude credentials (macOS Keychain first, then
~/.claude/.credentials.json) - If credentials are stale, triggers refresh via
claude -p . --model claude-haiku-4-5 - Re-reads credentials after the refresh attempt
- Stores OAuth tokens in OpenCode auth storage
| Priority | Source | Platform |
|---|---|---|
| 1 | macOS Keychain (Claude Code-credentials) |
macOS only |
| 2 | ~/.claude/.credentials.json |
All platforms |
Note: Override with
CLAUDE_CODE_AUTH_CREDENTIALS_PATHorCLAUDE_CODE_AUTH_KEYCHAIN_SERVICEenv vars.
- Refresh triggers when credentials expire (with 60s skew by default)
- On 401/403 responses, a forced refresh is attempted
- If refresh fails, you'll see:
Claude session is still expired. Run \claude auth login --claudeai` and try again.`
Best for: users who do not want Claude Code installed.
- Plugin generates PKCE values and an Anthropic OAuth authorization URL
- You open the URL in your browser and sign in
- Paste the returned authorization code back into OpenCode
- Plugin exchanges the code for access + refresh tokens
- Tokens are stored in OpenCode auth storage
opencode auth login -p anthropic → Browser sign-in → Open URL → Sign in → Paste code
Tip: If you receive a
code#statevalue, paste the whole thing.
- Refresh tokens are used to obtain new access tokens automatically
- On 401/403 responses, a forced token refresh is attempted
- If the refresh token itself is invalid, you'll need to re-login
Best for: users who want the simplest path.
- Uses standard Anthropic API key authentication
- No plugin-managed OAuth, no refresh logic
- OpenCode handles this path directly
| Your situation | Recommended method |
|---|---|
| Already use Claude Code | Claude Code session |
| Don't want to install Claude Code | Browser sign-in |
| Have an Anthropic API key | API key |
| Want the best auto-refresh | Claude Code session |
| Using a headless/CI environment | API key |