0

I am trying to use the Spring Cloud GCP. I want to know how to programmatically load GCP credentials rather than loading the GCP credentials from a json file using spring.cloud.gcp.credentials.location .

Does creating a bean of type com.google.auth.Credentials let Spring-Boot auto-configure Spring-Cloud-GCP correctly to use within the application?

If not, what is the way to inject Credentials so that Spring Cloud GCP is configured correctly?

YCN
  • 667
  • 2
  • 9
  • 25

1 Answers1

1

Not Credentials, but a bean of type CredentialsProvider will take precedence over any properties/autoconfiguration.

It's a functional interface, so you can return a lambda:

        @Bean
        public CredentialsProvider credentialsProvider() {
            return () -> NoCredentialsProvider.create().getCredentials();
        }
Elena Felder
  • 456
  • 3
  • 8