0

How to specify the GCP Credential Location in the application.properties file (for using the Pub/Sub in GCP)?

I am facing the below issue.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'firestoreOptions' defined in class path resource [org/springframework/cloud/gcp/autoconfigure/firestore/GcpFirestoreAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.cloud.firestore.FirestoreOptions]: Factory method 'firestoreOptions' threw exception; nested exception is java.lang.RuntimeException: Failed to obtain credentials
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]



Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:134) ~[google-auth-library-oauth2-http-0.26.0.jar:na]
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:120) ~[google-auth-library-oauth2-http-0.26.0.jar:na]

enter image description here

Rajesh Lohith
  • 426
  • 3
  • 10
  • Try running this command `gcloud auth application-default login`. Also check this stackoverflow link [1](https://stackoverflow.com/questions/72153978), [2](https://stackoverflow.com/questions/30982121/default-credential-for-app-engine-project-accessing-google-cloud-storage) ,[3](https://stackoverflow.com/questions/66452523/the-application-default-credentials-are-not-available-with-environment-variable) ,[4](https://stackoverflow.com/questions/51127494/define-google-application-credentials-for-google-cloud-speech-java-desktop-app) – Sathi Aiswarya May 23 '23 at 07:53

0 Answers0