[BUG] claude setup-token/CLAUDE_CODE_OAUTH_TOKEN is not enough to authenticate claude
Status Open
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 15 comments · opened Oct 4, 2025
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I ran claude setup-token, got the token and exported in CLAUDE_CODE_OAUTH_TOKEN.
Run claude in a fresh container (where claude was never run before) with the exported token. Claude walks me through the usual startup process, theme, choice of authentication (oauth, anthropic key). I was expecting it to just start and be ready for operation
What Should Happen?
When claude is started with an exported CLAUDE_CODE_OAUTH_TOKEN it should just start without asking for authorization.
Error Messages/Logs
Steps to Reproduce
- Run
claude setup-token - export CLAUDE_CODE_OAUTH_TOKEN
- rm -rf .claude*
- claude
- claude asks for theme and authentication
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.5 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
15 Comments
What's Wrong?
I am using Docker so wanted to use the OAuth token instead of browser authorization. On my host I ran claude setup-token which gave me the token and stated: Use this token by setting: export CLAUDE_CODE_OAUTH_TOKEN=<token> but to get claude CLI to use the token in the Docker container I needed to, instead, set ANTHROPIC_AUTH_TOKEN
The user experience when running Claude inside a container is poor. The browser authorization is not providing an option to get a code that can then be copy pasted into the Claude CLI. It is frusrtating that claude CLI asks for a code to be copied in but there is no explanatin of how/where to get this code (and it is not the OAuth token it seems.
What Should Happen?
Use the correct env variable name in the message or in the code.
Error Messages/Logs
Steps to Reproduce
Try using Claude from inside a docker container without running it on the host.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
No response
Claude Code Version
v2.0.14
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
I am running into this bug too v2.0.20. I have no way automating the authentication in the container. Even if i store the containers .claude folder via a mount it still doesn't work when i restore the container.
You could try this:
A) On the host run claude and login
Copy ~/.claude/.credentials.json from host into the container
B) On the host run claude setup-token
In the container: export ANTHROPIC_AUTH_TOKEN=xxx
This leads to:
API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"req_011CU8zCB1vunUftWrzbJGmC"}
Then unset ANTHROPIC_AUTH_TOKEN
Now it will use the ~/.claude/.credentials.json
Yes, copying the credentials works... it's just that CLAUDE_CODE_OAUTH_TOKEN would make life simpler. For some reason you need
~/.claude.jsontoo, though.Actually,
CLAUDE_CODE_OAUTH_TOKENworks for interactive mode; you just need to enablehasCompletedOnboarding: truein ~/.claude.json to skip onboarding process. I use this in devcontainer and it works.And I believe setting
ANTHROPIC_AUTH_TOKENwill do the same thing to sethasCompletedOnboardingto true. That's why it works when unsetANTHROPIC_AUTH_TOKEN.@chunlea I guess
claudecould figure that if the token is being used, no onboarding is needed.Exactly. This issue is a bit infuriating because it involves the other level of automation during setup. With CLAUDE_CODE_OAUTH_TOKEN I can just set the token env variable, but in order to make it work I have to create or copy the claude.json file, which has to contain more then one entry (otherwise I guess it can brake something)
I tried it using the SDK (passing the
CLAUDE_CODE_OAUTH_TOKENenv) and it worked with the onboarding flag set in the~/.claude.jsonfile.Taras Yarema
On 4 Dec 2025 at 20:12 +0100, Igor @.***>, wrote:
I use
jqto configure claude.json file. code is here.I've also hit this issue and finally got a solution. I was running Ubuntu 24.04.3 LTS on my proxmox home lab. The documentation file explains what I was running into, but more importantly, the claude_oauth_fix.sh script is what was used to solve this problem.
claude_oauth_fix.sh
CLAUDE_CODE_OAUTH_FIX_DOCUMENTATION.md
@edronen you are my hero!
wow this is still the issue which is very confusing. @bcherny we need your help here so much pls 😭 it's impossible to automate Claude on container
Still hitting this in v2.1.50. Building a tool (Grove) that runs Claude Code in Docker containers, and the onboarding blocks automated startup every time even with:
CLAUDE_CODE_OAUTH_TOKENenv var set (auth works fine in--printmode)~/.claude.jsonwith validoauthAccountbind-mounted~/.claude/settings.jsonwith"theme": "dark"bind-mountedWorkarounds I've found:
hasCompletedOnboarding: truein~/.claude.json(per @chunlea's comment) — works but fragile since.claude.jsonis prone to corruption from concurrent writes when bind-mountedIS_DEMO=trueenv var — documented to skip onboarding, but also hides email from UI and suppresses!-prefixed debug commands--dangerously-skip-permissions— the officially recommended flag for containers, but it refuses to run as root (--dangerously-skip-permissions cannot be used with root/sudo privileges), and many container setups default to rootWhat would actually fix this:
Claude should detect that
CLAUDE_CODE_OAUTH_TOKENis set and skip the interactive onboarding entirely — no theme picker, no trust dialog. If credentials are present, the user clearly intends to run headlessly/automated. A dedicated--skip-onboardingflag orCLAUDE_CODE_SKIP_ONBOARDING=1env var would also work.This fixed worked for me on my Mac! I struggled with this for HOURS until I came across this. I was up and running in minutes afterward. THANK YOU!
this still works well! thanks a lot 👍