Skip to content

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

Open

Description

@samodadela

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

Activity

  1. added
    bug
    on Oct 4, 2025
  2. added
    has repro
    platform:linux
    on Oct 4, 2025
  3. markNZed commented on Oct 11, 2025

    @markNZed

    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= 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

  4. wiltaylor commented on Oct 17, 2025

    @wiltaylor

    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.

  5. markNZed commented on Oct 17, 2025

    @markNZed

    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
    
  6. samodadela commented on Oct 23, 2025

    @samodadela
    Author

    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.

  7. chunlea commented on Oct 24, 2025

    @chunlea

    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.

  8. samodadela commented on Nov 5, 2025

    @samodadela
    Author

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

  9. rimmer commented on Dec 4, 2025

    @rimmer

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

  10. tarasyarema commented on Dec 4, 2025

    @tarasyarema
  11. chunlea commented on Dec 7, 2025

    @chunlea

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

  12. 8 remaining items

  13. gwonhong commented on Jun 1, 2026

    @gwonhong

    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 👍

  14. dtinth commented on Sep 9, 2026

    @dtinth

    One liner command to fix with jq:

    jq '.hasCompletedOnboarding = true' ~/.claude.json > /tmp/claude.json.tmp && mv /tmp/claude.json.tmp ~/.claude.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authbughas reproplatform:linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions