[BUG] Invalid API key · Please run /login (Linux)

Resolved 💬 4 comments Opened Aug 28, 2025 by llbbl Closed Sep 1, 2025

Claude Code CLI version 1.0.96 fails to create OAuth credentials file after successful authentication in Linux
container environments. The /login command reports "Login successful" but no .credentials.json file is created
anywhere on the filesystem, and subsequent commands fail with "invalid API key" errors.

Environment

  • Claude Code Version: 1.0.96
  • Platform: Linux container (Docker)
  • Base Image: node:20
  • Container User: node (non-root)
  • Host OS: macOS (Docker Desktop)

Steps to Reproduce

  1. Run Claude Code CLI in Linux container:

docker run --rm -it node:20 bash
npm install -g @anthropic-ai/claude-code

  1. Attempt authentication:

claude auth login

  1. Complete OAuth flow in browser (link opens successfully)
  2. Browser shows "Login successful" message
  3. Check authentication status and credentials:

claude auth status
find / -name ".credentials.json" 2>/dev/null
find / -name "credentials.json" 2>/dev/null
ls -la ~/.claude/
ls -la ~/.config/claude/

Expected Behavior

  • OAuth credentials should be saved to ~/.claude/.credentials.json (or similar location)
  • Credentials file should exist on filesystem after successful login
  • claude auth status should show authenticated state
  • Subsequent Claude commands should work without authentication errors

Actual Behavior

  • No .credentials.json file is created anywhere on the filesystem
  • Directory ~/.claude/ exists
  • claude auth status reports authentication failure/invalid API key
  • All subsequent Claude commands fail with authentication errors
  • OAuth flow appears to complete successfully but tokens are not persisted

Additional Information

  • The OAuth redirect flow completes successfully in the browser with "Login successful" message
  • Issue is specific to Linux container environments
  • Same authentication process works correctly on macOS host
  • Problem persists across different container configurations and users (root/non-root)
  • No permission errors or filesystem issues evident in container logs
  • Issue affects production Docker-based automation workflows

Impact

This blocks automated Docker-based workflows that depend on Claude Code CLI authentication, particularly CI/CD pipelines and containerized development environments where OAuth credential persistence is required.

View original on GitHub ↗

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