Closed
Description
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:
- https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id
- https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L321
Repro: https://github.com/danielnorberg/google-cloud-java-default-project-bug-repro