If you're using OpenCode with Anthropic’s Claude and suddenly started seeing errors like:
invalid tokenauthentication failedunauthorized request
You're not alone.
But here's the good news — there is a working solution, and you can get everything running again in just a couple of minutes.
🚀 The Solution (Works Right Now)
I built a small open-source plugin that restores Claude access inside OpenCode using OAuth:
👉 https://github.com/rokeyxuhleremny1/invalid-token-opencode
What it does
- Lets you log in with your Claude Pro / Max account
- Restores access to all Anthropic models
- Fixes broken token flows
- Requires no Claude Code installation
- Handles authentication automatically
⚡ Quick Setup
Install the plugin:
npm install -g opencode-anthropic-oauth
Add it to your config:
{
"plugin": ["opencode-anthropic-oauth"]
}
Then run:
/connect
or:
oc auth login
Select:
Anthropic → Claude Pro/Max
Complete the browser login → paste the code → done.
✅ Claude is working again.
🧠 How It Works
Instead of relying on broken token handling, this plugin:
- Uses OAuth (PKCE flow)
- Authenticates via browser (secure login)
- Exchanges auth code for access + refresh tokens
- Automatically refreshes tokens
- Injects correct API headers into OpenCode
👉 Result: stable, working integration with Anthropic again.
🔑 Alternative Option
If you want something more “official”:
- Use Anthropic API keys
- Pay-as-you-go
- No dependency on subscription tokens
But for many users, OAuth is the fastest way to get back up and running.
⚠️ Important Disclaimer
This solution uses Anthropic’s public OAuth client.
According to their Terms of Service (Feb 2026):
- Subscription tokens are intended for official clients only
This is a community workaround and may stop working if things change.
💥 What Actually Happened (Why Everything Broke)
Recently, Anthropic changed how authentication works.
This caused:
- OpenCode integrations to fail
- Tokens from Claude Pro/Max to stop working
- Massive “invalid token” errors across the community
In short:
👉 You could no longer use your subscription tokens outside official tools.
This broke workflows for a lot of developers using:
- OpenCode
- Cursor
- custom clients
🧾 Final Thoughts
AI tooling is moving fast — and sometimes platforms lock things down.
When that happens, the community adapts.
This plugin is one of those adaptations — simple, practical, and working right now.
If this helped you, feel free to ⭐ the repo:
👉 https://github.com/rokeyxuhleremny1/invalid-token-opencode
Top comments (0)