From 8d61fbcfc28075a69e54842fe7ae4d6030e69011 Mon Sep 17 00:00:00 2001 From: claude Date: Tue, 29 Jul 2025 21:11:18 +0000 Subject: [PATCH] Fix OAuth authentication by using claude_code_oauth_token parameter - Extract access token from credentials JSON in prepare.ts - Pass token to base action via claude_code_oauth_token parameter - Remove unused OAuth setup code and CLAUDE_CREDENTIALS env var - This uses the official base action's OAuth support correctly --- action.yml | 3 +-- src/entrypoints/prepare.ts | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index e350dbe..dd47174 100644 --- a/action.yml +++ b/action.yml @@ -109,7 +109,6 @@ runs: GITEA_API_URL: ${{ env.GITHUB_SERVER_URL }} # Only set ANTHROPIC_API_KEY if not using OAuth ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key != 'use-oauth' && inputs.anthropic_api_key || '' }} - CLAUDE_CREDENTIALS: ${{ inputs.claude_credentials }} - name: Run Claude Code id: claude-code @@ -125,6 +124,7 @@ runs: use_bedrock: ${{ inputs.use_bedrock }} use_vertex: ${{ inputs.use_vertex }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_code_oauth_token: ${{ steps.prepare.outputs.claude_oauth_token }} env: # Core configuration PROMPT_FILE: /tmp/claude-prompts/claude-prompt.txt @@ -138,7 +138,6 @@ runs: USE_VERTEX: ${{ inputs.use_vertex }} # Only set ANTHROPIC_API_KEY if not using OAuth ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key != 'use-oauth' && inputs.anthropic_api_key || '' }} - CLAUDE_CREDENTIALS: ${{ inputs.claude_credentials }} # GitHub token for repository access GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }} diff --git a/src/entrypoints/prepare.ts b/src/entrypoints/prepare.ts index fda8119..280ae7c 100644 --- a/src/entrypoints/prepare.ts +++ b/src/entrypoints/prepare.ts @@ -18,7 +18,6 @@ import { createPrompt } from "../create-prompt"; import { createClient } from "../github/api/client"; import { fetchGitHubData } from "../github/data/fetcher"; import { parseGitHubContext } from "../github/context"; -import { setupOAuthCredentials } from "../claude/oauth-setup"; async function run() { try { @@ -28,10 +27,19 @@ async function run() { // Check if OAuth credentials are provided and API key is empty (OAuth mode) if (claudeCredentials && !anthropicApiKey) { - await setupOAuthCredentials(claudeCredentials); - console.log( - "OAuth credentials configured for Claude AI Max subscription", - ); + // Parse the credentials to extract the access token + try { + const parsedCredentials = JSON.parse(claudeCredentials); + if (parsedCredentials.claudeAiOauth?.accessToken) { + // Output the access token for the base action to use + core.setOutput("claude_oauth_token", parsedCredentials.claudeAiOauth.accessToken); + console.log("OAuth access token extracted for Claude AI Max subscription"); + } else { + throw new Error("Invalid credentials format: missing claudeAiOauth.accessToken"); + } + } catch (error) { + throw new Error(`Failed to parse OAuth credentials: ${error instanceof Error ? error.message : String(error)}`); + } } // Step 2: Setup GitHub token