You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,17 +46,30 @@ There are multiple ways to authenticate to use Google Cloud services.
46
46
2. When using `gcloud-java` libraries elsewhere, there are two options:
47
47
*[Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). After downloading that key, you must do one of the following:
48
48
* Define the environment variable GOOGLE_APPLICATION_CREDENTIALS to be the location of the key. For example, `export GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/key.json`
49
-
* Supply the downloaded JSON credentials file when building the options supplied to datastore/storage constructor. For example, `StorageOptions.builder().authCredentials(AuthCredentials.createForJson(new FileInputStream("/path/to/my/key.json")).build().service()` returns a `Storage` object that has the necessary permissions.
49
+
* Supply the JSON credentials file when building the service options. For example, this Storage object has the necessary permissions to interact with your Google Cloud Storage data:
*If running locally for development/testing, you can use use [GoogleCloudSDK](https://cloud.google.com/sdk/?hl=en). To use the SDK authentication, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already. Then login using the SDK (`gcloud auth login` in command line), and set your current project using `gcloud config set project PROJECT_ID`.
51
57
52
58
`gcloud-java` looks for credentials in the following order, stopping once it finds credentials:
53
59
54
-
1. Credentials supplied to the `DatastoreOptions`/`ServiceOptions` builder
60
+
1.Credentials supplied when building the service options
55
61
2.AppEngine credentials
56
62
3.Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
57
-
4. Google SDK credentials
63
+
4.GoogleCloudSDK credentials
58
64
5.ComputeEngine credentials
59
65
66
+
Note that this sequence is different than the order in which `gcloud-java` determines the project ID. The project ID is determined in the following order:
67
+
68
+
1.ProjectID supplied when building the service options
69
+
2.ProjectID specified by the environment variable `GCLOUD_PROJECT`
0 commit comments