Skip to content

Authenticate the Claude Code workflow with a subscription OAuth token - #1180

Merged
busbyk merged 4 commits into
mainfrom
busbyk/claude-oauth-token-auth
Aug 7, 2026
Merged

Authenticate the Claude Code workflow with a subscription OAuth token#1180
busbyk merged 4 commits into
mainfrom
busbyk/claude-oauth-token-auth

Conversation

@busbyk

@busbyk busbyk commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Switches .github/workflows/claude.yml from the token-usage-billed ANTHROPIC_API_KEY to claude_code_oauth_token, so @claude mentions run on the organization's Claude subscription instead. anthropics/claude-code-action@v1 declares claude_code_oauth_token as an explicit alternative to anthropic_api_key and forwards it to the CLI as CLAUDE_CODE_OAUTH_TOKEN, so this is a one-line swap.

This cannot merge until the CLAUDE_CODE_OAUTH_TOKEN repo secret exists — it does not today. Mint it with claude setup-token from an account on the org subscription (prefer a shared account over a personal one, so the secret survives personnel changes) and add it first, or @claude will fail with no credentials.

Related Issues

Part of #1179. The other two consumers named in that issue are deferred: the size-gate rework has nothing to apply to until #1178 merges, and the visual-recap job is blocked upstream because BuilderIO/agent-native's reusable workflow declares no CLAUDE_CODE_OAUTH_TOKEN secret. Both are documented with the specific upstream touchpoints in this comment.

Key Changes

  • .github/workflows/claude.ymlanthropic_api_keyclaude_code_oauth_token
  • docs/claude-github-issues.md — troubleshooting section now names the new secret
  • drift.lock — binds that doc to claude.yml so drift flags it if the workflow's auth changes again

How to test

Note that issues / issue_comment workflows only ever run from the default branch, so this branch's claude.yml cannot be exercised by an @claude mention pre-merge. Test in this order:

  1. Validate the token out-of-band before it goes anywhere near CI: env -u ANTHROPIC_API_KEY CLAUDE_CODE_OAUTH_TOKEN='<token>' claude -p 'reply with OK'. Catches a wrong account, an expired token, or a missing subscription.
  2. Add the CLAUDE_CODE_OAUTH_TOKEN repo secret.
  3. Optional end-to-end check before merge: temporarily add a push-triggered scratch workflow on this branch (push events do run workflows from the pushed ref) that invokes anthropics/claude-code-action@v1 with the same input, then delete it before merge.
  4. After merge, @claude on a throwaway issue and confirm the run authenticates in the Actions tab.

Low risk either way — the failure mode is "@claude stops responding," not a production impact, and revert is one commit.

Future enhancements / Questions

ANTHROPIC_API_KEY is intentionally left in repo secrets: #1178's pr-visual-recap.yml still references it and has no other credential until the upstream piece lands. One known minor behavior change — the action's inline-comment classifier reads only ANTHROPIC_API_KEY, so unconfirmed buffered comments now post unclassified instead of being filtered. Comments Claude posts with confirmed: true (the normal review path) are unaffected, and the fallback is the action's own documented pre-buffering behavior.

busbyk and others added 2 commits August 7, 2026 12:08
`anthropics/claude-code-action@v1` accepts `claude_code_oauth_token` as an
alternative to `anthropic_api_key`, so `@claude` mentions can run on the
organization's Claude subscription instead of token-usage billing.

Requires the `CLAUDE_CODE_OAUTH_TOKEN` repo secret (minted with
`claude setup-token`) to exist before this merges.

Refs #1179

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Bind the doc to .github/workflows/claude.yml so drift flags it when the
workflow's auth changes again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Proves CLAUDE_CODE_OAUTH_TOKEN authenticates from a runner before claude.yml's
change reaches main. Delete before merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Served its purpose: run 31213153669 authenticated with CLAUDE_CODE_OAUTH_TOKEN
alone (no ANTHROPIC_API_KEY in scope) and returned a successful model response.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@busbyk

busbyk commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Ran the step-3 smoke test on this branch and it passed, so the subscription token is verified end-to-end from CI.

A temporary push-triggered workflow (added in 64d7336, removed in 10ba6f1 — not in the net diff) invoked the Claude Code CLI with CLAUDE_CODE_OAUTH_TOKEN as the only credential in the step env. Run 31213153669 went green in 9s with a real model response:

subtype          success
is_error         False
result           OAUTH OK
num_turns        1
duration_ms      1907

That establishes the two things worth knowing before merge: the token authenticates a real model call from a Blacksmith runner, and it does so with no ANTHROPIC_API_KEY present. Since action.yml forwards the claude_code_oauth_token input straight to that same env var, the remaining risk on this PR is close to nil.

Still post-merge-only: the actual @claude trigger path, since issues / issue_comment workflows run from the default branch. Worth an @claude on a throwaway issue right after merge.

@busbyk
busbyk added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit d1ab42d Aug 7, 2026
12 checks passed
@busbyk
busbyk deleted the busbyk/claude-oauth-token-auth branch August 7, 2026 20:10
busbyk added a commit that referenced this pull request Aug 7, 2026
The gate now judges borderline PRs by invoking Sonnet through the
Claude Code CLI with CLAUDE_CODE_OAUTH_TOKEN instead of calling the
Messages API with a usage-billed key, matching the subscription auth
adopted for @claude mentions in #1180. The recap job stays on
ANTHROPIC_API_KEY until BuilderIO/agent-native#2741 lets the reusable
workflow accept a subscription token.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant