[Question] How did you get Anthropic OAuth credentials? #1013

Closed
opened 2026-02-16 17:29:05 -05:00 by yindo · 6 comments
Owner

Originally created by @rmonvfer on GitHub (Jul 31, 2025).

Originally assigned to: @thdxr on GitHub.

Hello!

As the title says, I was wondering how did OpenCode manage to obtain OAuth credentials from Anthropic, which are then used to log into the API and enable Claude Code usage.

My apologies if this has already been answered but I haven't been able to find any documentation about this anywhere and the Anthropic documentation doesn't mention any procedure to obtain OAuth credentials.

I'm asking because OpenCode seems to be the only third-party tool that supports using a Claude Pro/Max subscription (other tools like Cline delegate authentication and usage to the Claude Code CLI itself and don't have direct API access).

Originally created by @rmonvfer on GitHub (Jul 31, 2025). Originally assigned to: @thdxr on GitHub. Hello! As the title says, I was wondering how did OpenCode manage to obtain OAuth credentials from Anthropic, which are then used to log into the API and enable Claude Code usage. My apologies if this has already been answered but I haven't been able to find any documentation about this anywhere and the Anthropic documentation doesn't mention any procedure to obtain OAuth credentials. I'm asking because OpenCode seems to be the only third-party tool that supports using a Claude Pro/Max subscription (other tools like Cline delegate authentication and usage to the Claude Code CLI itself and don't have direct API access).
yindo closed this issue 2026-02-16 17:29:05 -05:00
Author
Owner

@johanp95 commented on GitHub (Aug 4, 2025):

Lookng at https://github.com/sst/opencode/tree/dev/packages/opencode/src/auth/anthropic.ts, seems like OpenCode is basically copying Claude-Codes's credential flow. the client-id is the same as can be found in claude-code's cli.js.

@johanp95 commented on GitHub (Aug 4, 2025): Lookng at https://github.com/sst/opencode/tree/dev/packages/opencode/src/auth/anthropic.ts, seems like OpenCode is basically copying Claude-Codes's credential flow. the client-id is the same as can be found in claude-code's cli.js.
Author
Owner

@rmonvfer commented on GitHub (Aug 4, 2025):

I guess it makes sense to use the same client-id if there is no way to get one. Thank you!

@rmonvfer commented on GitHub (Aug 4, 2025): I guess it makes sense to use the same client-id if there is no way to get one. Thank you!
Author
Owner

@johanp95 commented on GitHub (Aug 6, 2025):

There is more to it than just the client ID though. Message me on twitter and I can let you know all the deets - YohaanhP

@johanp95 commented on GitHub (Aug 6, 2025): There is more to it than just the client ID though. Message me on twitter and I can let you know all the deets - YohaanhP
Author
Owner

@jiyans commented on GitHub (Aug 6, 2025):

I was interested in this as well, but I couldn't message you on twitter.. i followed you though

@jiyans commented on GitHub (Aug 6, 2025): I was interested in this as well, but I couldn't message you on twitter.. i followed you though
Author
Owner

@psense-account commented on GitHub (Nov 1, 2025):

If anyone is interested in how this is done, I've got it all documented with proof-of-concept code:

https://github.com/nsxdavid/anthropic-oauth-max-plan

You can also just follow along in the codebase here, but honestly, the nuances take some explanation.

@psense-account commented on GitHub (Nov 1, 2025): If anyone is interested in how this is done, I've got it all documented with proof-of-concept code: https://github.com/nsxdavid/anthropic-oauth-max-plan You can also just follow along in the codebase here, but honestly, the nuances take some explanation.
Author
Owner

@YlanAllouche commented on GitHub (Nov 7, 2025):

I guess we've all been working on the same thing.

Here is mine: https://github.com/YlanAllouche/ClaudeBridge

Does both Anthropic and OpenAI so you can funnel all of your usage through the one gateway which with the internal token system also allows you to monitor usage both in web ui and grafana by model/app for global or specific 5h/7d sessions.

This also makes an alternative to ccusage that does not rely on file storage.

@YlanAllouche commented on GitHub (Nov 7, 2025): I guess we've all been working on the same thing. Here is mine: https://github.com/YlanAllouche/ClaudeBridge Does both Anthropic and OpenAI so you can funnel all of your usage through the one gateway which with the internal token system also allows you to monitor usage both in web ui and grafana by model/app for global or specific 5h/7d sessions. This also makes an alternative to `ccusage` that does not rely on file storage.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1013