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
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user