Support read CREDENTIAL_ENV_VAR from VM option.
Hi team,
Can we support read CREDENTIAL_ENV_VAR from VM options?
Code snippet
String credentialsPath = this.getProperty(CREDENTIAL_ENV_VAR, this.getEnv(CREDENTIAL_ENV_VAR));
Can you elaborate on this? What problem does this solve? Why this choice of variable name? Thanks.
I'm trying to integrate the Google reCAPTCHA in the AWS Elastic Beanstalk environment Tomcat & Java application, but Google required one system environment variable for the default credentials, something like this: System.getenv("GOOGLE_APPLICATION_CREDENTIALS"), but looks like AWS ElasticBeanstalkEnvironment only supports the VM options. that's simple and easy if google can read CREDENTIAL_ENV_VAR from VM options, otherwise, I have to write few extra codes to read the credentials from VM options.
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(System.getProperty("GOOGLE_APPLICATION_CREDENTIALS", System.getenv("GOOGLE_APPLICATION_CREDENTIALS"))));
RecaptchaEnterpriseServiceSettings serviceSettings = RecaptchaEnterpriseServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = RecaptchaEnterpriseServiceClient.create(serviceSettings)) {
xxxx
}
instead of expect one:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = RecaptchaEnterpriseServiceClient.create()) {
xxx
}
so, is it that make sense to read the variable from VM options first and the system as the default? such as
String credentialsPath = this.getProperty(CREDENTIAL_ENV_VAR, this.getEnv(CREDENTIAL_ENV_VAR));
cc @lsirac Will the upcoming 3pi credentials work better for this use case?