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)