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)