[BUG] Claude Code npm package immediately enters interactive mode with OAuth expired error - authentication commands don't trigger OAuth flow

Status Fixed / completed
Maintainer reply None cached
Activity 8 comments · opened Jul 1, 2025 · closed Jul 28, 2025

Environment

  • Platform: Anthropic API
  • Claude CLI version: 1.0.39 (Claude Code)
  • Installation method: npm install -g @anthropic-ai/claude-code
  • Operating System: macOS
  • Terminal: Terminal.app and Cursor integrated terminal
  • Node version: v22.17.0 (also tested with v23.11.0)

Bug Description
Claude Code immediately enters interactive mode when running claude command, and all authentication-related commands fail with OAuth expired error without ever triggering the browser OAuth flow.

Steps to Reproduce

  1. Install Claude Code: npm install -g @anthropic-ai/claude-code
  2. Run claude
  3. Immediately drops into interactive mode with welcome message
  4. Try any auth command: login, auth login, authenticate, auth
  5. All return: API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new token or refresh your existing token."}}

Expected Behavior
Running claude login should open browser for OAuth authentication

Actual Behavior
Never reaches OAuth flow, immediately shows expired token error in interactive mode

Troubleshooting Attempted

  • Complete uninstall and cleanup of all config directories
  • Tested with Node v22 and v23
  • Removed macOS Keychain entries
  • Fresh install multiple times

View original on GitHub ↗

8 Comments

JorgeMadson · 1 year ago

I got this error, any work around? I will switch to local install until it is fixed.

Ps. I did a claude revalidate-token something (something like this) it opens the browser but I still got 401 after that. It seems to be down.

BE4YOU-do · 1 year ago

I have got it too, are there any solutions?

johnyjharris · 1 year ago

I am getting this on Max plan. Claude Code is not responding to any of my prompts or slash commands.

EDIT: I fixed this by /logout and then signing in again.

JorgeMadson · 1 year ago

Antropic server were down:

<img width="689" height="690" alt="Image" src="https://github.com/user-attachments/assets/fb92393f-19c3-4f14-8329-8ed98262ce96" />

Login out and login back also solved for me.

ivklgn · 1 year ago
EDIT: I fixed this by /logout and then signing in again.

thank you!
i tried without logout - just /login and it works!

vonjohn574 · 1 year ago
I am getting this on Max plan. Claude Code is not responding to any of my prompts or slash commands. EDIT: I fixed this by /logout and then signing in again.

fixed with /logout and /login, thanks!

clah82 · 1 year ago

I finally got it fixed:

The interactive login flow was broken, but direct token setup method worked for me.
Removed all Claude Code cache files, uninstalled the package, cleared npm cache, and reinstalled.
Used claude setup-token command since normal login command was broken.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.