Skip to content

CLAUDE_CODE_OAUTH_TOKEN is cleared between prepare and execute phases, causing authentication failure #676

@kernelsam

Description

@kernelsam

Describe the bug
The claude-code-action@v1 clears the CLAUDE_CODE_OAUTH_TOKEN environment variable after the preparation phase, causing the base-action execution to fail with an authentication error even though the token was properly provided.

To Reproduce
Steps to reproduce the behavior:

  1. Configure the action with CLAUDE_CODE_OAUTH_TOKEN in the env section:
- uses: anthropics/claude-code-action@v1
  env:
    CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
  with:
    prompt: |
      Review this PR…
  1. Run the workflow
  2. Observe that it fails with: Environment variable validation failed: Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required

Expected behavior
The CLAUDE_CODE_OAUTH_TOKEN should remain available throughout the entire action execution, allowing the action to authenticate successfully using the OAuth token.

Actual Behavior
The token is present during the prepare phase but gets cleared before the base-action execution phase:

# Prepare phase (working):
env:
  CLAUDE_CODE_OAUTH_TOKEN: ***

# Base-action execution phase (broken):
env:
  CLAUDE_CODE_OAUTH_TOKEN:    # <--- Empty!

This causes the action to fail with:
Error: Environment variable validation failed:

  • Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required when using direct Anthropic API.

Screenshots
If applicable, add screenshots to help explain your problem.

Workflow yml file
If it's not sensitive, consider including a paste of your full Claude workflow.yml file.

API Provider

[ ] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex

Additional context
Action version: anthropics/claude-code-action@v1 (SHA: 8a1c437)
Runner: ubuntu-latest (Ubuntu 24.04.3)
Bun version: 1.2.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:installationbugSomething isn't workingp1Showstopper bug preventing substantial subset of users from using the product, or incorrect docsprovider:1pAnthropic First-Party API

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions