anthropics / anthropics/claude-code-action

ANTHROPIC_AUTH_TOKEN not supported as standalone auth method

Open
#1,294 2 comments 1 reaction 0 assignees View on GitHub
bug feature-request p3
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

**Describe the bug**

The GitHub Action does not support `ANTHROPIC_AUTH_TOKEN` as a standalone authentication method. This variable is documented in the [official Claude Code env vars docs](https://code.claude.com/docs/en/env-vars) and the [authentication docs](https://code.claude.com/docs/en/authentication) as the recommended way to authenticate with custom providers/LLM gateways that use `Authorization: Bearer` headers.

Locally, setting `ANTHROPIC_AUTH_TOKEN` + `ANTHROPIC_BASE_URL` works out of the box. In the GitHub Action, it fails with:

```
Environment variable validation failed:
- Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required when using direct Anthropic API.
```

**To Reproduce**

1. Set `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL` as job-level environment variables (without setting `anthropic_api_key` input)
2. Run the action without `use_bedrock`, `use_vertex`, or `use_foundry`
3. Action fails with the validation error above

**Expected behavior**

The action should accept `ANTHROPIC_AUTH_TOKEN` as a valid standalone auth method and forward it to the CLI subprocess, matching the behavior of the CLI when run locally.

**Workflow yml file**

```yaml
- uses: anthropics/claude-code-action@v1
with:
github_token: ${{ steps.app-token.outputs.token }}
env:
ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_AUTH_TOKEN }}
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
```

**Workaround**

Pass the token as `anthropic_api_key` to satisfy validation, and use `ANTHROPIC_CUSTOM_HEADERS` to send the Bearer header:

```yaml
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_AUTH_TOKEN }} # just to pass validation
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
ANTHROPIC_CUSTOM_HEADERS: "Authorization: Bearer ${{ secrets.ANTHROPIC_AUTH_TOKEN }}"
```

This works but results in both `X-Api-Key` and `Authorization: Bearer` headers being sent.

Contributor guide

Open the contributing guide

Research direction

Start at the GitHub Action's environment-variable validation and CLI subprocess entry point, tracing the standalone ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL path. Use the reproduction workflow first, then confirm the action accepts that combination without anthropic_api_key and forwards it without requiring the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
authentication, ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.