[BUG] claude setup-token/CLAUDE_CODE_OAUTH_TOKEN is not enough to authenticate claude

Status Open
Maintainer reply None cached
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

  1. Run claude setup-token
  2. export CLAUDE_CODE_OAUTH_TOKEN
  3. rm -rf .claude*
  4. claude
  5. 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_

View original on GitHub ↗

15 Comments

markNZed · 10 months ago

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

wiltaylor · 10 months ago

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.

markNZed · 10 months ago

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

samodadela · 10 months ago

Yes, copying the credentials works... it's just that CLAUDE_CODE_OAUTH_TOKEN would make life simpler. For some reason you need ~/.claude.json too, though.

chunlea · 10 months ago

Actually, CLAUDE_CODE_OAUTH_TOKEN works for interactive mode; you just need to enable hasCompletedOnboarding: true in ~/.claude.json to skip onboarding process. I use this in devcontainer and it works.

And I believe setting ANTHROPIC_AUTH_TOKEN will do the same thing to set hasCompletedOnboarding to true. That's why it works when unset ANTHROPIC_AUTH_TOKEN.

samodadela · 9 months ago

@chunlea I guess claude could figure that if the token is being used, no onboarding is needed.

rimmer · 8 months ago
@chunlea I guess claude could 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)

tarasyarema · 8 months ago

I tried it using the SDK (passing the CLAUDE_CODE_OAUTH_TOKEN env) and it worked with the onboarding flag set in the ~/.claude.json file.

Taras Yarema
On 4 Dec 2025 at 20:12 +0100, Igor @.***>, wrote:

rimmer left a comment (anthropics/claude-code#8938) > @chunlea I guess claude could 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) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
chunlea · 8 months ago
> @chunlea I guess claude could 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 use jq to configure claude.json file. code is here.

edronen · 7 months ago

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

grandcamel · 7 months ago

@edronen you are my hero!

vec715 · 6 months ago

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

GandalftheGUI · 6 months ago

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_TOKEN env var set (auth works fine in --print mode)
  • ~/.claude.json with valid oauthAccount bind-mounted
  • ~/.claude/settings.json with "theme": "dark" bind-mounted

Workarounds I've found:

  1. hasCompletedOnboarding: true in ~/.claude.json (per @chunlea's comment) — works but fragile since .claude.json is prone to corruption from concurrent writes when bind-mounted
  2. IS_DEMO=true env var — documented to skip onboarding, but also hides email from UI and suppresses !-prefixed debug commands
  3. --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 root

What would actually fix this:
Claude should detect that CLAUDE_CODE_OAUTH_TOKEN is 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-onboarding flag or CLAUDE_CODE_SKIP_ONBOARDING=1 env var would also work.

jsokol · 5 months ago
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

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!

gwonhong · 3 months ago
Actually, CLAUDE_CODE_OAUTH_TOKEN works for interactive mode; you just need to enable hasCompletedOnboarding: true in ~/.claude.json to skip onboarding process. I use this in devcontainer and it works.

this still works well! thanks a lot 👍