Skip to content

Commit

Permalink
v1 -solve google auth credential error
Browse files Browse the repository at this point in the history
  • Loading branch information
git-create-devben committed Jul 18, 2024
1 parent 200ed20 commit 7dd7795
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/api/gemini/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ function initializeVertexAI() {
);
}

console.log("Credentials JSON type:", typeof credentialsJson);
console.log("Credentials JSON first 100 characters:", credentialsJson.substring(0, 100));

try {
const credentials = JSON.parse(credentialsJson);
console.log("Parsed credentials project_id:", credentials.project_id);
return new VertexAI({
project: process.env.PROJECT_ID,
location: "us-central1",
googleAuthOptions: credentials,
// apiEndpoint: credentials
});
} catch (error) {
} catch (error: any) {
console.error("Error parsing GOOGLE_APPLICATION_CREDENTIALS_JSON:", error);
throw new Error("Invalid GOOGLE_APPLICATION_CREDENTIALS_JSON");
throw new Error("Invalid GOOGLE_APPLICATION_CREDENTIALS_JSON", error.message + error);
}
}

Expand Down

0 comments on commit 7dd7795

Please sign in to comment.