[BUG] Possible Issue: Environment Variables ANTHROPIC_AUTH_TOKEN and CLAUDE_CODE_OAUTH_TOKEN May Interfere with Local Interactive Mode

Resolved 💬 6 comments Opened Sep 19, 2025 by outsideshot Closed Jan 8, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Description:
I've observed that setting ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN as environment variables seems to cause Claude Code's local interactive mode to fail with authentication errors, even when running locally (not over SSH). I'm not certain if this is a bug or expected behavior, but it was quite confusing to debug.

What I Experienced:

  1. I set these environment variables while trying to debug SSH access: export ANTHROPIC_AUTH_TOKEN="some_value"
  2. Interactive mode stopped working locally: claude gave authentication errors
  3. This happened even though I was running locally, not over SSH

What I Expected:
I assumed local interactive mode would work regardless of these environment variables, or there would be documentation warning about potential conflicts.

What Actually Happened:
Interactive mode appeared to fail with authentication errors when these variables were set, even when running locally.

Possible Cause:
It seems like Claude might be attempting to use these environment variables for authentication, possibly bypassing the OAuth flow? Since they were likely invalid for interactive mode, authentication failed. But I'm not entirely sure about this.

Workaround That Helped Me:

unset ANTHROPIC_AUTH_TOKEN
unset CLAUDE_CODE_OAUTH_TOKEN

After removing these, local interactive mode worked again.

Suggestions (if this is indeed an issue):

  1. Perhaps document this interaction if it's expected behavior?
  2. Maybe add a warning when these variables are detected?
  3. Could these variables be ignored for interactive mode OAuth flow?

Environment:

  • Claude Code version: Latest
  • OS: macOS
  • Installation method: npm

This caused me quite a bit of debugging time while trying to get SSH access working. I had set these variables while troubleshooting, not realizing they might affect local access too. Others might be experiencing similar confusion.

I'm happy to provide more details or test further if that would be helpful!

What Should Happen?

What I Expected:
I assumed local interactive mode would work regardless of these environment variables, or there would be documentation warning about potential conflicts.

Error Messages/Logs

Steps to Reproduce

  1. Set environment variable (trying to debug SSH access):

```bash
export ANTHROPIC_AUTH_TOKEN="any_value"
# or
export CLAUDE_CODE_OAUTH_TOKEN="any_value"

  1. Try to start interactive mode locally (not over SSH):

claude

  1. Observe authentication error despite being in local terminal
  2. To verify it's the env vars causing it:

unset ANTHROPIC_AUTH_TOKEN CLAUDE_CODE_OAUTH_TOKEN
claude # Now works

  1. Setting them again breaks it:

export ANTHROPIC_AUTH_TOKEN="test"
claude # Fails again

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

1.0.119 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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