updated prepare.ts so Claude Code token written
This commit is contained in:
@@ -18,6 +18,7 @@ import { createPrompt } from "../create-prompt";
|
|||||||
import { createClient } from "../github/api/client";
|
import { createClient } from "../github/api/client";
|
||||||
import { fetchGitHubData } from "../github/data/fetcher";
|
import { fetchGitHubData } from "../github/data/fetcher";
|
||||||
import { parseGitHubContext } from "../github/context";
|
import { parseGitHubContext } from "../github/context";
|
||||||
|
import { setupOAuthCredentials } from "../claude/oauth-setup";
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@@ -27,18 +28,25 @@ async function run() {
|
|||||||
|
|
||||||
// Check if OAuth credentials are provided and API key is empty (OAuth mode)
|
// Check if OAuth credentials are provided and API key is empty (OAuth mode)
|
||||||
if (claudeCredentials && !anthropicApiKey) {
|
if (claudeCredentials && !anthropicApiKey) {
|
||||||
// Parse the credentials to extract the access token
|
// Write the credentials to the file system for Claude Code
|
||||||
try {
|
try {
|
||||||
const parsedCredentials = JSON.parse(claudeCredentials);
|
await setupOAuthCredentials(claudeCredentials);
|
||||||
if (parsedCredentials.claudeAiOauth?.accessToken) {
|
console.log("OAuth credentials written to ~/.claude/.credentials.json");
|
||||||
// Output the access token for the base action to use
|
|
||||||
core.setOutput("claude_oauth_token", parsedCredentials.claudeAiOauth.accessToken);
|
// Also extract the token for any other uses
|
||||||
console.log("OAuth access token extracted for Claude AI Max subscription");
|
try {
|
||||||
} else {
|
const parsedCredentials = JSON.parse(claudeCredentials);
|
||||||
throw new Error("Invalid credentials format: missing claudeAiOauth.accessToken");
|
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");
|
||||||
|
}
|
||||||
|
} catch (parseError) {
|
||||||
|
// Log but don't fail - credentials are already written
|
||||||
|
console.log("Could not extract OAuth token for output:", parseError);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to parse OAuth credentials: ${error instanceof Error ? error.message : String(error)}`);
|
throw new Error(`Failed to setup OAuth credentials: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user