When running on a GCE host, ServiceOptions.getDefaultProjectId() incorrectly returns the project id from the GCE metadata server instead of defaulting to the project ID specified in the JSON credentials file pointed by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
This seems to be due to getAppEngineProjectId() returning a project id even when running outside GAE, causing getDefaultProjectId() to not call getServiceAccountProjectId().
This seems to have been introduced in #3413 and resulted in the behavior changing from google-cloud-core 1.3.0 to 1.4.0.
Documentation:
Repro: https://github.com/danielnorberg/google-cloud-java-default-project-bug-repro
When running on a GCE host,
ServiceOptions.getDefaultProjectId()incorrectly returns the project id from the GCE metadata server instead of defaulting to the project ID specified in the JSON credentials file pointed by theGOOGLE_APPLICATION_CREDENTIALSenvironment variable.This seems to be due to
getAppEngineProjectId()returning a project id even when running outside GAE, causinggetDefaultProjectId()to not callgetServiceAccountProjectId().This seems to have been introduced in #3413 and resulted in the behavior changing from
google-cloud-core1.3.0to1.4.0.Documentation:
Repro: https://github.com/danielnorberg/google-cloud-java-default-project-bug-repro