diff --git a/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java b/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java index 8ffb77eaf5..231b9040c9 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java +++ b/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java @@ -327,7 +327,11 @@ protected ServiceOptions( quotaProjectId = builder.quotaProjectId != null ? builder.quotaProjectId - : getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "quota_project_id"); + : getValueFromCredentialsFile(getCredentialsPath(), "quota_project_id"); + } + + private static String getCredentialsPath() { + return System.getProperty(CREDENTIAL_ENV_NAME, System.getenv(CREDENTIAL_ENV_NAME)); } /** @@ -511,7 +515,7 @@ static boolean headerContainsMetadataFlavor(HttpResponse response) { } protected static String getServiceAccountProjectId() { - return getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "project_id"); + return getValueFromCredentialsFile(getCredentialsPath(), "project_id"); } @InternalApi("Visible for testing")