-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Translate] Warning when using ADC + API Key #11060
Comments
@clundin25 Thanks for reporting this issue! I agree we should remove this warning. In addition, is the current authentication order correct? In which explicitly set Credentials has preference over API keys. Also moving this issue back to google-cloud-java as this is a handwritten layer on top of GAPIC(We do have a few of them in the mono repo). |
I think the order should be:
It's less clear to me what the ENV variable order should be. |
@clundin25 Would there be any problem if we change the order? The comment seems to indicate that the backend is expecting this specific order to avoid conflict. |
I don't think the issue is the order, rather that both the api key and credential are in the same request. If they are not source from the same project, the request will fail. So as long as the code chooses only one, it should not be a problem. |
Is Java the only language that flags an error if the two credentials are from a different project? What do other languages do in this situation-- and what order do they use? The last thing we need is different behavior depending on language. This should be spec'ed out somewhere. |
This enforced from the server so it should not work for any language.
I think only Python and Go support API keys for GAPIC, and neither support the env variable. I believe only this library and Ruby reference the "GOOGLE_API_KEY" ENV variable. PHP does seem to use it in a test case. https://github.com/search?q=org%3Agoogleapis+GOOGLE_API_KEY+-lang%3Amarkdown+-lang%3Ayaml&type=code |
Yes, this specific code is in handwritten only for this library. Other GAPIC libraries do not support API keys through client settings yet. We documented authenticating through headers in our README. |
Moving forward API key will have preference over ADC.
I believe this error message is unnecessary and possibly confusing for API key users.
Should it be removed?
google-cloud-java/java-translate/google-cloud-translate/src/main/java/com/google/cloud/translate/TranslateOptions.java
Line 166 in f16bc31
The text was updated successfully, but these errors were encountered: