Search code examples
springgoogle-cloud-vertex-aispring-ai

Spring AI - Authentication fails when using json file in spring.ai.vertex.ai.gemini.credentialsUri


I am trying to use VertexAIGeminiChat module in my spring boot app, but when I use a service account json file in credentialsUri, I get this error:

UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project


Solution

  • Adding the following property to application.properties file fixed the issue:

    spring.ai.vertex.ai.gemini.transport=rest