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:
claude
2025-07-29 21:11:18 +00:00
parent 2fb6134aa3
commit 8d61fbcfc2
2 changed files with 14 additions and 7 deletions

View File

@@ -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