[BUG] CLAUDE_CODE_OAUTH_TOKEN authorization not working
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?
Subject: Claude Code auth fails in interactive / agent mode on remote SSH desktop
Environment:
• Claude Code CLI on a remote Linux desktop (Ubuntu), accessed via SSH, bash shell. No local browser / GUI on the box.
Problem:
• Browser-based OAuth login can't be completed over SSH — the browser won't open on the remote machine, the "press c to copy URL" shortcut copies to the remote clipboard (inaccessible from my local machine), and manually selecting the printed URL fails (it appears to wrap across multiple lines).
• API-key auth works only partially:
– Direct curl to https://api.anthropic.com/v1/messages with the key → 200 OK.
– claude -p "..." works after exporting ANTHROPIC_API_KEY (an earlier 401 was caused by the variable being set but not exported, so child processes didn't inherit it).
– Interactive claude and agent sessions still force a login prompt.
• Also seeing the auth-conflict warning when both ANTHROPIC_API_KEY and CLAUDE_CODE_OAUTH_TOKEN are present; the OAuth token var was only an empty leftover. claude setup-token isn't an option here since it also requires a browser.
Already tried: adding export to the key, claude /logout, inspecting env vars, and checking for forceLogin in ~/.claude/settings.json and project .claude/settings.json.
Questions:
- Is there a managed/enterprise settings.json (e.g. forceLoginMethod) or a company API gateway (ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN) configured on these dev desktops that would force Claude.ai login and prevent API-key auth in interactive mode?
- What's the approved authentication method for Claude Code on headless / SSH dev machines here — company-issued API key or gateway, or a subscription OAuth token?
- If OAuth is required, is there an out-of-band way to complete it on a box with no browser?
(API key omitted intentionally for security.)
What Should Happen?
I should be able to set CLAUDE_CODE_OAUTH_TOKEN and use claude code (also via claude agents) with no hiccups
Error Messages/Logs
Steps to Reproduce
- No steps since I am not able to log in
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.183
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗