From cf6ac54e46b55a22a459746a1bfd896a2ea298cb Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 4 Apr 2016 17:43:09 +0200 Subject: [PATCH] First look for AE's project id, then GOOGLE_APPLICATION_CREDENTIALS' --- README.md | 4 ++-- .../src/main/java/com/google/gcloud/ServiceOptions.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 939914b4fb5e..6bd1e7211f2c 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,8 @@ Most `gcloud-java` libraries require a project ID. There are multiple ways to s 1. Project ID supplied when building the service options 2. Project ID specified by the environment variable `GCLOUD_PROJECT` -3. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable -4. App Engine project ID +3. App Engine project ID +4. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable 5. Google Cloud SDK project ID 6. Compute Engine project ID diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java index 5432deadaa8e..d53cfcdafe24 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java @@ -383,10 +383,10 @@ protected String defaultHost() { protected String defaultProject() { String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME)); if (projectId == null) { - projectId = serviceAccountProjectId(); + projectId = appEngineProjectId(); } if (projectId == null) { - projectId = appEngineProjectId(); + projectId = serviceAccountProjectId(); } return projectId != null ? projectId : googleCloudProjectId(); }