DEV Community

anthopen
anthopen

Posted on

OpenCode + Claude Broken? Fix "invalid token" and Restore Anthropic Access

OpenCode + Claude Broken? Fix "invalid token" and Restore Anthropic Access

If you're using OpenCode with Claude, you probably hit this recently:

  • invalid token
  • authentication 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 token errors
  • 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"]
}
Enter fullscreen mode Exit fullscreen mode

Run:

```bash id="0kchxy"
/connect




or:



```bash id="zv6h0s"
oc auth login
Enter fullscreen mode Exit fullscreen mode

Then:

  1. Select Anthropic β†’ Claude Pro/Max
  2. Open browser login
  3. 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 token errors

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)