Currently we infer project ID only from the Compute Engine metadata server (if available).
While I don't think there's a documented recipe for how to infer the project, the way that we have for application default credentials, there are some common practices being used (still somewhat inconsistently) by the auth libraries for other languages:
Honor the GOOGLE_CLOUD_PROJECT (and the legacy GCLOUD_PROJECT) environment variables, which are set in the App Engine Flexible Environment, and also often set by applications. (example from nodejs)
Honor DEVSHELL_PROJECT_ID environment variable, which is set by Google Cloud Shell. (example from ruby)
Try to grab it from the gcloud sdk if it is present.
I can provide a pull request if you agree with these.
Currently we infer project ID only from the Compute Engine metadata server (if available).
While I don't think there's a documented recipe for how to infer the project, the way that we have for application default credentials, there are some common practices being used (still somewhat inconsistently) by the auth libraries for other languages:
GOOGLE_CLOUD_PROJECT
(and the legacyGCLOUD_PROJECT
) environment variables, which are set in the App Engine Flexible Environment, and also often set by applications. (example from nodejs)DEVSHELL_PROJECT_ID
environment variable, which is set by Google Cloud Shell. (example from ruby)I can provide a pull request if you agree with these.