[BUG] /login for OAuth clobbers existing API key authentication

Resolved 💬 2 comments Opened Mar 31, 2026 by gensanMasterclass Closed Jun 1, 2026

Description

Running /login to authenticate with a claude.ai account (required for /schedule) overrides an existing, working ANTHROPIC_API_KEY session — not just in the current terminal, but across all running Claude Code instances. Every open session switches from API key auth to OAuth, effectively logging the user out everywhere.

Steps to reproduce

  1. Have multiple Claude Code sessions running, all authenticated via ANTHROPIC_API_KEY
  2. Run /login in any one session to authenticate with a claude.ai account (needed for /schedule)
  3. OAuth login succeeds
  4. All Claude Code instances lose API key auth and switch to OAuth — not just the session where /login was run

Expected behavior

/login should add OAuth credentials alongside the existing API key auth, not replace it. At minimum, it should only affect the session where /login was run, not globally clobber auth across all instances.

Workarounds

None currently — /login is destructive to all running sessions. Restarting the shell restores API key auth from the environment, but any in-progress work in other sessions is disrupted.

Environment

  • macOS (Darwin 24.6.0)
  • Auth method: ANTHROPIC_API_KEY environment variable

Related

  • #25069 — macOS keychain/OAuth logic preempting ANTHROPIC_API_KEY

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗