Skip to content

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

Closed

Description

@rmonvfer

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).

Activity

  1. self-assigned this
    on Aug 1, 2025
  2. johanp95 commented on Aug 4, 2025

    @johanp95

    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.

  3. rmonvfer commented on Aug 4, 2025

    @rmonvfer
    Author

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

  4. johanp95 commented on Aug 7, 2025

    @johanp95

    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

  5. jiyans commented on Aug 7, 2025

    @jiyans

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

  6. psense-account commented on Nov 1, 2025

    @psense-account

    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.

  7. YlanAllouche commented on Nov 7, 2025

    @YlanAllouche

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions