[Translate] Warning when using ADC + API Key
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?
https://github.com/googleapis/google-cloud-java/blob/f16bc31f2e0e9e3febab45a214e48688d46b49eb/java-translate/google-cloud-translate/src/main/java/com/google/cloud/translate/TranslateOptions.java#L166
@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:
// 1. explicitly set API key
// 2. explicitly set credentials
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.
Is Java the only language that flags an error if the two credentials are from a different project?
This enforced from the server so it should not work for any language.
What do other languages do in this situation-- and what order do they use?
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
only this library
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.
fixed with PR