Skip to content

fix: use ANTHROPIC_AUTH_TOKEN for managed account providers (Copilot/Codex)#4063

Open
runyuxu wants to merge 1 commit into
farion1231:mainfrom
runyuxu:fix/copilot-use-auth-token
Open

fix: use ANTHROPIC_AUTH_TOKEN for managed account providers (Copilot/Codex)#4063
runyuxu wants to merge 1 commit into
farion1231:mainfrom
runyuxu:fix/copilot-use-auth-token

Conversation

@runyuxu

@runyuxu runyuxu commented Jun 11, 2026

Copy link
Copy Markdown

Problem

When GitHub Copilot or Codex OAuth is set as the active provider, the ManagedAccount auth policy writes ANTHROPIC_API_KEY=PROXY_MANAGED into ~/.claude/settings.json.

Claude Code CLI's login check recognises ANTHROPIC_AUTH_TOKEN as the session credential. When only ANTHROPIC_API_KEY is present with a placeholder value, the CLI shows:

Not logged in · Please run /login

on every new terminal session, even though the proxy is running and requests are succeeding.

Users on PreserveExistingOrAuthToken providers (e.g. direct Anthropic API) don't hit this because that policy defaults to writing ANTHROPIC_AUTH_TOKEN when no pre-existing key is found.

Fix

Change ManagedAccount policy to write ANTHROPIC_AUTH_TOKEN=PROXY_MANAGED instead of ANTHROPIC_API_KEY=PROXY_MANAGED, consistent with what Claude Code expects for session auth.

Test plan

  • Updated 3 existing tests to assert ANTHROPIC_AUTH_TOKEN is set and ANTHROPIC_API_KEY is absent after takeover (Copilot and Codex cases)
  • Open CC Switch with Copilot as active provider → new terminal claude should not show "Not logged in"

🤖 Generated with Claude Code

…d account providers

GitHub Copilot and Codex OAuth providers use the ManagedAccount auth
policy, which previously wrote ANTHROPIC_API_KEY=PROXY_MANAGED into
the Claude config. Claude Code CLI's login check recognises
ANTHROPIC_AUTH_TOKEN as the session credential; when only
ANTHROPIC_API_KEY is present with a placeholder value, the CLI shows
"Not logged in · Please run /login" on every startup.

Fix the ManagedAccount policy to write ANTHROPIC_AUTH_TOKEN=PROXY_MANAGED
instead, consistent with how PreserveExistingOrAuthToken handles the
case where no pre-existing token key is found.

Update tests accordingly.
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants