GeezerVison is showing github.com — SpeechAPI samples and docs do not show how to pass credentials · Issue #697 · GoogleCloudPlatform/java-docs-samples
SpeechAPI samples and docs do not show how to pass credentials #697DescriptionI am trying to do some test using the Google Speech API but from outside Google Cloud. In the older beta version I was able to specify a credentials file but now I am unable to find this option in the SpeechClient class.
How can I go about specifying the authentication keys using the Google Speech API Java library? I believe a sample code should be added to demonstrate this (both passing flat credentials and using a credentials file)
P.S I already asked the same exact question on SO but 4 days later and still no one answered Reacted by Swapnil Sawant and Jimi Wang Activityfrankyn commented on Jun 13, 2017 frankyn commented on Jun 15, 2017 redserpent7 commented on Jun 18, 2017 @frankyn thanks but I am really interested in setting the credentials path as a configuration variable. Namely I want to do the exact same thing described here but in Java frankyn commented on Jun 19, 2017 @gguuss do you know how to set credentials programmatically? frankyn commented on Jun 19, 2017 @redserpent7, I was able to set credentials using the following flow. I'd still like your input @gguuss when you have a moment.
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream("/path/to/service-account.json")));
ChannelProvider channelProvider = SpeechSettings.defaultChannelProviderBuilder().setCredentialsProvider(credentialsProvider).build();
SpeechSettings settings = SpeechSettings.defaultBuilder().setChannelProvider(channelProvider).build();
// Instantiates a client
SpeechClient speech = SpeechClient.create(settings);Reacted by tamirmich, hua21best, ShemerKuznits and Owen Gallagher gguuss commented on Jun 19, 2017 @frankyn -- you're doing it correctly, in the builder you just provide an API key or service account credential. For the samples, we are using the Application default credentials because it's simpler and more secure configuration. Reacted by Frank Natividad frankyn commented on Jun 19, 2017 redserpent7 commented on Jun 20, 2017 @frankyn Perfect thank you so much. And I hope you update the documentation to show that frankyn commented on Jun 20, 2017 Great! Let us know if anything else comes up! We will update the documentation with this information soon. frankyn commented on Jun 20, 2017 Solido commented on Jun 27, 2017 Using Gax:grpc 0.21.1 I got .setCredentialsProvider marked as deprecated and my json auth that is working well when loaded with GoogleCredentials on gcloud storage throws
The Application Default Credentials are not available using the previous snippet with Speech Api.
Asking for GOOGLE_APPLICATION_CREDENTIALS and ignoring the conf. Reacted by Swapnil Sawant, Daniel Zurek and Houssainatou Charles92011 commented on Oct 9, 2017 @frankyn I'm trying your solution, but it doesn't work for me.
SpeechSettings.defaultChannelProviderBuilder is undefined
SpeechSettings.defaultBuilder is deprecated
and SpeechSettings.defaultBuilder,setChannelProvider is undefined.
Your solution is only a couple of months old, I can't image it's out of date. Charles92011 commented on Oct 9, 2017 @Solido I gleaned this from a comment inside of SpeechClient.Java, it works for me:
FileInputStream credentialsStream = new FileInputStream(fileName);
GoogleCredentials credentials = GoogleCredentials.fromStream(credentialsStream);
FixedCredentialsProvider credentialsProvider = FixedCredentialsProvider.create(credentials);
SpeechSettings speechSettings =
SpeechSettings.newBuilder()
.setCredentialsProvider(credentialsProvider)
.build();
SpeechClient speech = SpeechClient.create(speechSettings);
Reacted by Saquibul Islam Waheed, Ernesto Perez, Jimi Wang, Kevin Piazzoli Felix Perez, Avanika Gabani, tamirmich, hua21best, Robert Felker, Samuel Humeau, Vasil Vasilev and 4 more Reacted by Jonathan and Avanika Gabani Reacted by Hasitha Jayawardana ihunzai-dev commented on Feb 2, 2018 export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json is not working @frankyn
I have already set env variable using the command, but client library is still throwing same Exception
OS: Ubuntu 16.0 Server hua21best commented on Jul 23, 2019
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|