I want to use a different credentials file when creating my Annotator client. I am currently able to do it with the transalte API like so:
Credentials creds = ServiceAccountCredentials.fromStream(new FileInputStream("path/to/credentials.json"));
return TranslateOptions.newBuilder().setCredentials(creds).build().getService();
Is there an equivalent way of doing it with the ImageAnnotatorClient
?
Edit: I am working with google cloud java sdk version: 1.16.0
Credentials
🔗 -> CredentialsProvider
🔗
ImageAnnotatorSettings.Builder
-> ImageAnnotatorSettings
-> ImageAnnotatorClient
Example (mostly copied from the docs):
Credentials myCredentials = ServiceAccountCredentials.fromStream(
new FileInputStream("path/to/credentials.json"));
ImageAnnotatorSettings imageAnnotatorSettings =
ImageAnnotatorSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ImageAnnotatorClient imageAnnotatorClient =
ImageAnnotatorClient.create(imageAnnotatorSettings);
com.google.cloud.vision.v1.ImageAnnotatorClient
🔗
com.google.cloud.vision.v1.ImageAnnotatorSettings
🔗
com.google.api.gax.rpc.ClientSettings.Builder
🔗
com.google.api.gax.core.FixedCredentialsProvider
🔗
com.google.auth.oauth2.ServiceAccountCredentials
🔗
Note: The above is for Java. The API for C# is different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With