You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Java, we can have "system properties" as well as "environment variables" that keep our map between keys and string values.
We access system properties using the method System.getProperty while to access the environment variables we use System.getenv.
Different systems may use different approaches to pass configurations. For instance, Amazon Elastibewnsatck passes our variables to Tomcat as properties that will have to be accessed using System.getProperty (see link here).
Currently, DefaultCredentialsProvider reads GOOGLE_APPLICATION_CREDENTIALS only using System.getenv (apart from using getWellKnownCredentialsFile).
It would be nice if it could also try to read the credentials from properties.
I was unable to send a pull request (permission denied), so here goes the draft code I think would easily fix the issue:
New method for DefaultCredentialsProvider:
Change line 135 of DefaultCredentialsProvider#getDefaultCredentialsUnsynchronized from: String credentialsPath = getEnv(CREDENTIAL_ENV_VAR);
to: String credentialsPath = getEnvOrProperty(CREDENTIAL_ENV_VAR);
Another approach would be to modify GoogleAuthUtils#getWellKnownCredentialsFile to add a new clause based on getProperty and the default CREDENTIAL_ENV_VAR.
The text was updated successfully, but these errors were encountered:
Hi Rafael, thanks for suggestion and explaining the use case. It makes sense and we can consider it as a feature request. I will update sometime later if we pick it up.
BTW, you can submit PRs using fork-PR strategy. It does not require any extra access. But for this particular thing I would suggest to wait for an update. This is because ADC logic follow the AIP: https://google.aip.dev/auth/4110 and an update would be a cross-language change.
Also, the are more variables involved in authentication, like quota project, mtls, etc. The change would have to cover all of those variables as well.
In Java, we can have "system properties" as well as "environment variables" that keep our map between keys and string values.
We access system properties using the method System.getProperty while to access the environment variables we use System.getenv.
Different systems may use different approaches to pass configurations. For instance, Amazon Elastibewnsatck passes our variables to Tomcat as properties that will have to be accessed using System.getProperty (see link here).
Currently, DefaultCredentialsProvider reads GOOGLE_APPLICATION_CREDENTIALS only using System.getenv (apart from using getWellKnownCredentialsFile).
It would be nice if it could also try to read the credentials from properties.
I was unable to send a pull request (permission denied), so here goes the draft code I think would easily fix the issue:
New method for DefaultCredentialsProvider:
Change line 135 of DefaultCredentialsProvider#getDefaultCredentialsUnsynchronized from:
String credentialsPath = getEnv(CREDENTIAL_ENV_VAR);
to:
String credentialsPath = getEnvOrProperty(CREDENTIAL_ENV_VAR);
Another approach would be to modify GoogleAuthUtils#getWellKnownCredentialsFile to add a new clause based on getProperty and the default CREDENTIAL_ENV_VAR.
The text was updated successfully, but these errors were encountered: