Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpeechAPI samples and docs do not show how to pass credentials #697

Closed
redserpent7 opened this issue Jun 11, 2017 · 15 comments
Closed

SpeechAPI samples and docs do not show how to pass credentials #697

redserpent7 opened this issue Jun 11, 2017 · 15 comments
Assignees

Comments

@redserpent7
Copy link

redserpent7 commented Jun 11, 2017

I 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

@frankyn
Copy link
Member

frankyn commented Jun 13, 2017

Hi @redserpent7,

Thanks for reaching out!

You can authenticate using a service-account and setting the environment variable:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

Instructions on creating a service account and setting the environment variable can be found at:
https://cloud.google.com/docs/authentication/getting-started

@frankyn
Copy link
Member

frankyn commented Jun 15, 2017

@redserpent7 did this help?

@frankyn frankyn self-assigned this Jun 15, 2017
@redserpent7
Copy link
Author

@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
Copy link
Member

frankyn commented Jun 19, 2017

@gguuss do you know how to set credentials programmatically?

@frankyn
Copy link
Member

frankyn commented 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);

@gguuss
Copy link
Contributor

gguuss commented 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.

@frankyn
Copy link
Member

frankyn commented Jun 19, 2017

Thanks @gguuss! @redserpent7 let us know if this worked for you.

@redserpent7
Copy link
Author

@frankyn Perfect thank you so much. And I hope you update the documentation to show that

@frankyn frankyn closed this as completed Jun 20, 2017
@frankyn
Copy link
Member

frankyn commented Jun 20, 2017

Great! Let us know if anything else comes up! We will update the documentation with this information soon.

@frankyn
Copy link
Member

frankyn commented Jun 20, 2017

I posted this answer to your stackoverflow question as well.

@Solido
Copy link

Solido commented 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.

@Charles92011
Copy link

@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
Copy link

@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);		

@ihunzai-dev
Copy link

ihunzai-dev commented 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
Copy link

@redserpent7 @Charles92011 thanks,Very useful to me

minherz pushed a commit that referenced this issue Nov 9, 2022
🤖 I have created a release \*beep\* \*boop\*
---
### Updating meta-information for bleeding-edge SNAPSHOT release.
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
minherz pushed a commit that referenced this issue Nov 10, 2022
🤖 I have created a release \*beep\* \*boop\*
---
### Updating meta-information for bleeding-edge SNAPSHOT release.
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
minherz pushed a commit that referenced this issue Nov 10, 2022
🤖 I have created a release \*beep\* \*boop\*
---
### Updating meta-information for bleeding-edge SNAPSHOT release.
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
charlieyu1996 pushed a commit that referenced this issue Nov 10, 2022
…1.0 (#697)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | `24.0.0` -> `24.1.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/24.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/24.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/24.1.0/compatibility-slim/24.0.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/24.1.0/confidence-slim/24.0.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-talent).
charlieyu1996 pushed a commit that referenced this issue Nov 11, 2022
…uration to v1.2.0 (#697)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud.samples:shared-configuration](https://togithub.com/GoogleCloudPlatform/java-repo-tools) | `1.0.23` -> `1.2.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.samples:shared-configuration/1.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.samples:shared-configuration/1.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.samples:shared-configuration/1.2.0/compatibility-slim/1.0.23)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.samples:shared-configuration/1.2.0/confidence-slim/1.0.23)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>GoogleCloudPlatform/java-repo-tools</summary>

### [`v1.2.0`](https://togithub.com/GoogleCloudPlatform/java-repo-tools/compare/v1.0.24...v1.2.0)

[Compare Source](https://togithub.com/GoogleCloudPlatform/java-repo-tools/compare/v1.0.24...v1.2.0)

### [`v1.0.24`](https://togithub.com/GoogleCloudPlatform/java-repo-tools/compare/v1.0.23...v1.0.24)

[Compare Source](https://togithub.com/GoogleCloudPlatform/java-repo-tools/compare/v1.0.23...v1.0.24)

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-datacatalog).
Sita04 pushed a commit that referenced this issue Nov 11, 2022
….2 (#697)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.seleniumhq.selenium:selenium-java](https://selenium.dev/) ([source](https://togithub.com/SeleniumHQ/selenium)) | `4.1.1` -> `4.1.2` | [![age](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/compatibility-slim/4.1.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/confidence-slim/4.1.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-recaptchaenterprise).
Sita04 pushed a commit that referenced this issue Nov 15, 2022
….2 (#697)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.seleniumhq.selenium:selenium-java](https://selenium.dev/) ([source](https://togithub.com/SeleniumHQ/selenium)) | `4.1.1` -> `4.1.2` | [![age](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/compatibility-slim/4.1.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.seleniumhq.selenium:selenium-java/4.1.2/confidence-slim/4.1.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-recaptchaenterprise).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants