Using CodeCompanion with Anthropic signed-in account (Like Claude Code) #1984
andtankian
started this conversation in
Show and tell
Replies: 3 comments 26 replies
-
Oh my god, man, you're amazing |
Beta Was this translation helpful? Give feedback.
0 replies
-
I tried to create an adapter with oauth flow, now the oauth flow has passed, but when requesting, the token will report the lack of scope. I also encountered this problem in opencode. https://github.com/jinzhongjia/codecompanion.nvim/tree/anthropic_oauth |
Beta Was this translation helpful? Give feedback.
19 replies
-
Should I copy the whole
|
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This isn’t the most conventional approach — but it works.
Antropic.Logged.mp4
Claude Code lets you use an Anthropic Pro subscription account and call Claude models without being charged for wasted API tokens. Of course, there’s a daily quota, but in my experience it’s surprisingly generous — I was able to work the entire day without hitting the limit. That’s incredible, considering how expensive Anthropic tokens normally are.
To figure out how Claude Code manages this, I read through some docs and ran a man-in-the-middle proxy to capture the requests and responses being sent to Anthropic’s API. Here’s what I found:
Authorization
header.How do you get a valid signed-in token?
On macOS:
Open the Keychain Access app and search for “Claude Code”. View the entry to reveal the token, then export it to an environment variable:
export ANTHROPIC_BEARER_TOKEN=xxxx
On other systems:
Use a tool like
mitmproxy
to intercept Claude Code’s traffic, then capture and copy the bearer token from one of the API calls.I’ve now built a simple custom adapter that lets our CodeCompanion plugin use Anthropic as if we were logged in through Claude Code — without needing a direct API key:
(Paste this in y
It will be awesome if someone get this adapter as inspiration to make the OAuth authentication as well.
Beta Was this translation helpful? Give feedback.
All reactions