OpenCode + Claude Broken? Fix "invalid token" and Restore Anthropic Access
If you're using OpenCode with Claude, you probably hit this recently:
invalid tokenauthentication failed- Claude just stopped responding
No warning. No clear explanation. Just broken workflows.
Letโs fix that.
๐ The Fix (Working Right Now)
Thereโs a simple workaround that restores Claude access using OAuth:
๐ https://github.com/rogoltmalki766/opencode-anthropic-oauth
This plugin allows you to log in with your Claude Pro / Max account directly inside OpenCode โ no Claude Code, no manual tokens.
What you get
- Claude working again in OpenCode
- Full access to Anthropic models
- No more
invalid tokenerrors - Automatic authentication + refresh
โก Setup (Takes 1 Minute)
Install:
```bash id="c7z8p1"
npm install -g opencode-anthropic-oauth
Add plugin:
```json id="cbq6lq"
{
"plugin": ["opencode-anthropic-oauth"]
}
Run:
```bash id="0kchxy"
/connect
or:
```bash id="zv6h0s"
oc auth login
Then:
- Select
Anthropic โ Claude Pro/Max - Open browser login
- Paste the code
โ Done. Claude is back.
๐ง Why This Works
Instead of relying on outdated token methods, this uses:
- OAuth PKCE flow
- Official Anthropic auth endpoints
- Browser-based login (secure)
- Access + refresh token lifecycle
๐ In short: it mimics a real login instead of relying on static tokens.
๐ Alternative (Official Way)
If you want something fully compliant:
- Use Anthropic API keys
- Pay per usage
- Works everywhere
- No dependency on subscriptions
But:
๐ธ Itโs more expensive
โ๏ธ Requires manual setup
๐ฅ What Broke OpenCode?
Anthropic recently tightened how authentication works.
That led to:
- Subscription tokens no longer working externally
- OpenCode integrations breaking
- Widespread
invalid tokenerrors
Basically:
You canโt use Claude Pro/Max tokens outside official clients anymore.
โ ๏ธ Disclaimer
This solution uses Anthropicโs public OAuth client.
According to their ToS (Feb 2026):
- Subscription tokens are intended for official use
๐ This is a workaround
๐ It may break in the future
Use it carefully.
๐งพ Final Thoughts
AI tools are moving toward closed ecosystems.
But developers will always find ways to:
- stay flexible
- avoid lock-in
- keep building
If your workflow broke โ now you know how to fix it.
โญ If this helped you:
๐ https://github.com/rogoltmalki766/opencode-anthropic-oauth
Top comments (0)