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)