Skip to content

[BUG] CLAUDE_CODE_OAUTH_TOKEN authorization not working #69753

Description

@hridayesh-joshi-ai

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:

  1. 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?
  2. 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?
  3. 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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions