"Not logged in · Please run /login" Claude Code
Quick fix
Upgrade cc-switch to v3.19.2+, or change ANTHROPIC_API_KEY to ANTHROPIC_AUTH_TOKEN in settings.json by hand to skip the approval prompt.
Symptom
Section titled “Symptom”Not logged in · Please run /loginIn early cc-switch versions, taking over Claude Code with a managed account such as GitHub Copilot injected the proxy token as the environment variable ANTHROPIC_API_KEY. Claude Code then raises a custom API key approval prompt in interactive mode, defaulting to No — and accepting that default discards the key, leaving you logged out. Non-interactive (headless) mode works fine because it never triggers the prompt.
Upgrade cc-switch to v3.19.2 or newer and enable proxy takeover again; it now uses the ANTHROPIC_AUTH_TOKEN environment variable, which needs no approval.
If you cannot upgrade yet, edit the Claude Code config file by hand and change the environment variable name from ANTHROPIC_API_KEY to ANTHROPIC_AUTH_TOKEN.
// ~/.claude/settings.json{"env": {"ANTHROPIC_API_KEY": "PROXY_MANAGED","ANTHROPIC_AUTH_TOKEN": "PROXY_MANAGED","ANTHROPIC_BASE_URL": "http://127.0.0.1:15721"}}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 5 real issues
- Why does non-interactive mode work while interactive mode says not logged in?
- Non-interactive mode never triggers the Claude Code custom API key approval prompt, so the proxy token is read directly. Interactive mode raises the prompt and defaults to refusing, so the key is discarded.
- With the proxy on, why do I still see Claude models in Claude Code?
- With the proxy on, cc-switch takes over provider model mapping inside the proxy. The Claude Code UI still shows Claude models, but the actual requests are already mapped to your custom model.
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.