I am building springboot application that uses Google Cloud Platform Vision API, to use Google cloud platform, the credentials is required so I am trying to configure it but it does not talk it and talk the credentials way in the code, I want to use the credentials that into application.properties, how to do that?
Configuration class
@Configuration
public class VisionConfiguration {
@Bean
public CloudVisionTemplate cloudVisionTemplate() throws IOException {
Credentials credentials = new Credentials();
return new CloudVisionTemplate(imageAnnotatorClient(new DefaultCredentialsProvider(() -> credentials)));
}
@Bean
ImageAnnotatorClient imageAnnotatorClient(CredentialsProvider credentialsProvider) throws IOException {
ImageAnnotatorSettings settings = ImageAnnotatorSettings
.newBuilder()
.setCredentialsProvider(credentialsProvider)
.build();
return ImageAnnotatorClient.create(settings);
}
}
application.properties
spring.cloud.gcp.credentials.location=credentials.json
and I put the credentials json file under resource folder
could any one help?