Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) - Claude
Quick fix
Delete primaryApiKey from claude.json, or change the environment variable to ANTHROPIC_API_KEY, to resolve the auth conflict.
Symptom
Section titled “Symptom”Auth conflict:Both a token (ANTHROPIC_AUTH_TOKEN) and an API key (/login managed key) are set. This may lead to unexpected behavior.When switching to a third-party provider, cc-switch writes ANTHROPIC_AUTH_TOKEN into settings.json by default. If you previously signed in to Claude Code officially, claude.json still holds a primaryApiKey field, and having both present makes Claude Code report the Auth conflict error. Separately, for a Claude Desktop direct provider the client expects to read ANTHROPIC_API_KEY, so the default ANTHROPIC_AUTH_TOKEN also fails authentication.
Delete the API key left behind by the official login: open claude.json and remove the primaryApiKey field.
// ~/.claude/claude.json{"primaryApiKey": "sk-ant-..."}Alternatively, change the environment variable name in the config from ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY, for Claude Desktop compatibility or to avoid the header conflict.
// ~/.claude/settings.json{"env": {"ANTHROPIC_AUTH_TOKEN": "your-token","ANTHROPIC_API_KEY": "your-token"}}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 5 real issues
- #288switch provider will override some other variables in env
- #366为什么直接把我原有的配置全部覆盖了啊?
- #913如何配置供应商类型
- #1049CC Switch配置模型后,终端Claude显示Auth conflict:Both a token (ANTHROPIC_AUTH_TOKEN) and an API key (/login managed key) are set. This may lead to unexpected behavior.
- #5669bug(claude-desktop): direct providers default to ANTHROPIC_AUTH_TOKEN
- Why does switching provider in cc-switch overwrite my existing hooks, permissions, and similar config?
- That is expected. Some providers have unique fields (CLAUDE_CODE_MAX_OUTPUT_TOKENS, for example), and to stop fields from different providers interfering — causing errors or hurting performance — cc-switch rewrites the config file. Use the general config feature to write shared configuration quickly.
- My provider forbids sending Authorization and x-auth-api headers together. What now?
- While editing the provider in cc-switch, set the auth field to ANTHROPIC_API_KEY (Bearer mode), or add "auth_mode": "bearer_only" to the config to disable x-api-key.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.