Skip to content

Commit 84eef77

Browse files
committed
---
yaml --- r: 2427 b: refs/heads/update-datastore c: 0a04229 h: refs/heads/master i: 2425: e05e401 2423: 8def21f
1 parent 5187590 commit 84eef77

3 files changed

Lines changed: 51 additions & 5 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
66
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
8-
refs/heads/update-datastore: 076127d6ce599716519eeffd5595fe8c5313b5df
8+
refs/heads/update-datastore: 0a04229286ef4b79e37073f75e2c60339e225b99
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,61 @@ Example Applications
4545
- [`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
4646
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html).
4747

48+
Specifying a Project ID
49+
-----------------------
50+
51+
Most `gcloud-java` libraries require a project ID. There are multiple ways to specify this project ID.
52+
53+
1. When using `gcloud-java` libraries from within Compute/App Engine, there's no need to specify a project ID. It is automatically inferred from the production environment.
54+
2. When using `gcloud-java` elsewhere, you can do one of the following:
55+
* Supply the project ID when building the service options. For example, to use Datastore from a project with ID "PROJECT_ID", you can write:
56+
57+
```java
58+
Datastore datastore = DatastoreOptions.builder().projectId("PROJECT_ID").build().service();
59+
```
60+
* Specify the environment variable `GCLOUD_PROJECT` to be your desired project ID.
61+
* Set the project ID using the [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already, and set the project ID from the command line. For example:
62+
63+
```
64+
gcloud config set project PROJECT_ID
65+
```
66+
67+
`gcloud-java` determines the project ID from the following sources in the listed order, stopping once it finds a value:
68+
69+
1. Project ID supplied when building the service options
70+
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
71+
3. App Engine project ID
72+
4. Compute Engine project ID
73+
5. Google Cloud SDK project ID
74+
4875
Authentication
4976
--------------
5077

5178
There are multiple ways to authenticate to use Google Cloud services.
5279

5380
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
5481
2. When using `gcloud-java` libraries elsewhere, there are two options:
55-
* [Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). Supply a path to the downloaded JSON credentials file when building the options supplied to datastore/storage constructor.
56-
* If running locally for development/testing, you can use use [Google Cloud SDK](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`.
82+
* [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:
83+
* Define the environment variable GOOGLE_APPLICATION_CREDENTIALS to be the location of the key. For example:
84+
```bash
85+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/key.json
86+
```
87+
* 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:
88+
```java
89+
Storage storage = StorageOptions.builder()
90+
.authCredentials(AuthCredentials.createForJson(new FileInputStream("/path/to/my/key.json"))
91+
.build()
92+
.service();
93+
```
94+
* If running locally for development/testing, you can use use Google Cloud SDK. Download the SDK if you haven't already, then login using the SDK (`gcloud auth login` in command line). Be sure to set your project ID as described above.
95+
96+
`gcloud-java` looks for credentials in the following order, stopping once it finds credentials:
97+
98+
1. Credentials supplied when building the service options
99+
2. App Engine credentials
100+
3. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
101+
4. Google Cloud SDK credentials
102+
5. Compute Engine credentials
57103
58104
Google Cloud Datastore
59105
----------------------

branches/update-datastore/gcloud-java-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
<dependency>
2121
<groupId>com.google.auth</groupId>
2222
<artifactId>google-auth-library-credentials</artifactId>
23-
<version>0.1.0</version>
23+
<version>0.3.0</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>com.google.auth</groupId>
2727
<artifactId>google-auth-library-oauth2-http</artifactId>
28-
<version>0.1.0</version>
28+
<version>0.3.0</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>com.google.http-client</groupId>

0 commit comments

Comments
 (0)