Claude Code Max auth
How do you retain the authentications for one User across multiple workspaces for a Claude code max plan that does not use api keys?
63 Replies
<#1416506087724679309>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Hi @Sebo we are making it easy in our Claude Code module.
The new version should be availble later today,
cc: @35C4n0r
https://github.com/coder/registry/pull/402/files#diff-3f433388cb775dcc77c38911e23acbd2eb64e26e26c25d46b045724dfe5136bbR30
Will it retain the Session Token across multiple workspaces ? Or do i need to call Claude setup-token in every workspace again?
I think it should
I believe that you need to pass your anthropic token. This is how I do it for my sessions.
Is there now an anthropic token for subscription based pricing too?
it does, i'm using with session token for a while by now
i have a older module version but setting this var instead of the token one should work

Also i've pinned CC version to 1.0.100, as it has a bug that configure your instance as PRO plan instead of Max

not sure if they resolved this yet, but i had this problem between 1.0.101 to 1.0.108
just for ref, https://github.com/anthropics/claude-code/issues/6955
GitHub
[Bug] Claude Code fails to recognize MAX subscription tier - defaul...
Environment Platform (select one): Anthropic API AWS Bedrock Google Vertex AI Other: Claude Code CLI Claude CLI version: 1.0.43 (Claude Code) (also tested with v1.0.98) Operating System: macOS 15.6...
btw, good to hear about the new version, i'll update my templates later today
You guys here at Coder rocks!
@ztlod ツ where do you get the OAUTH_Token from? Thanks
Hey, @Sebo
first run claude and authenticate (/login)
then kill the process and run
claude auth-token
and it will give a long-living token
btw, forget the first step, if i`m not mistaken the command will ask you to login againah nice
hm doesn't seem to work for me.
wait, let me double check the command, i've did this step days ago
the command don't run?
sry
claude setup-token
is the right command
nice this works. awesome
The token generation part worked, but claude still wants to login again. Not sure why it is not working
Hi try using the new v3.0.0 module and you should be able to pass a session token
Thanks. I actually wanted to use claude code in tmux in a workspace. It works by retaining the claude.json config file and setting the env var that you mentioned. Thanks everyone for helping out. Your messages helped me figuring it out. 🚀
Wanted to bump this one. I previously had this working, but using Oauth, I now get an authentication error. This github issue is the same: https://github.com/anthropics/claude-code/issues/9802
GitHub
Cannot --resume. OAuth authentication errors contaminating session ...
Bug Description Claude Code --resume Bug Report Summary: Sessions opened via --resume disappear from the resume list on subsequent runs due to OAuth authentication errors contaminating session file...
This is same: https://github.com/anthropics/claude-code/issues/5956
GitHub
OAuth Authentication Not Supported for Highest Plan Tier · Issue #...
Bug Description I have subscribed to highest plan. But I am getting this error related to auth. API Error: 401 {"type":"error","error":{"type":"authenti...
i'm still have it working on my templates
what cc version are you using?
Latest version. 2.0.22

agent api

and my setup is configured with OAUTH + CC Module
Mine also worked, and workspaces that were logged in work, but new ones don't. I can reproduce issue inside a docker container, claude just doesn't seem to care that you have an OAUTH token.
what version of cc module are you using?
let me check mine
latest.

Try a fresh docker container just something plain, pass the ENV var for the token, and it says oauth not supported, must login.
for sure. but i run my WK on incus, not docker
Hold on I can share a snippet.
but i'll spin up a new one
The issue isn't even CC module, just claude in general seems to not care about oauth anymore.
just for ref

empty template from scratch
spinning up, incus take a while
I have a test image and build it. then passing oauth token gets this.
just simple image like this:
here,

let me check, but i think this env name are wrong ANTHROPIC_AUTH_TOKEN
try CLAUDE_CODE_OAUTH_TOKEN
both env names from the docs not working for me.
try and let me know
Will do. If you're getting something, I must have it messed somewhere. Just don't know where.
on my workspace
printenv
it uses CLAUDE_CODE_OAUTH_TOKEN not anthropic
this one ANTHROPIC_AUTH_TOKEN don't exist on my envs at all
I will try to see what I am doing wrong. I think it's ANTROPIC api key and cc oauth token are conflicting, and I didn't realize. Thanks for the help
It is sent in env, but claude doesn't pick it up.



Terminal or the claude-code web module.
this is the way I am testing it locally:
This results in getting asked for login. I see yours works, but even a simple reproduction locally does not work for me.
run a normal bash without token
printenv then unset every token related to anthropic or claudecode
then run export CLAUDE_CODE_OAUTH_TOKEN="put token here" claude
I did, it's empty just claude code. From what I found, it needs ~/.claude.json or just won't work.
I think I see why not working for me. In dockerfile, we are installing claude code, not installing with claude-code web. I am guessing the install for claude-code module does something to setup .claude.json maybe. Or, that's what it seems like.
yes, claude_code module does create a .claude config
Thanks. Makes sense.
give up on the minimal test, update your template and try the full cenario
Sorry to jump in here so late. Solution for us was also that there needs to be a claude config already in place for it to work otherwise claude code goes through the login process again. @noel
Yes. I finally found the missing base .claude.json that’s needed. Thanks Sebo!
With this we were able to put an input field into the new workspace creation form that says "what is your initial prompt?". Then the engineer can start a workspace with coder already starting a tmux claude code session after the workspace is love. In the meantime the engineer can work on something else and come back once the initial output e.g. creating a specification is done.
Yes exactly what I am doing. I’m passing all my stuff from GitHub issues. I add a label and it launches the workspace in full force. Kind of amazing!
Nice
How do you connect the both?
Up
I want to know aswell
:thonk:
I can share a GitHub action. But essentially it’s just environment vars and coder cli.
My prompt for this just says here’s the issue #. Here’s coding guidelines. Here’s playwright MCP server you have access to. And now use the GitHub CLI tool to pull up the issue description and execute on it till it’s complete. I wasted a bunch of time trying to figure out how to dependably pass through huge issue descriptions, using gh cli is easier.