Skip to content

Commit 820e7b2

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 1887 b: refs/heads/pubsub-alpha c: c084250 h: refs/heads/master i: 1885: 9a50383 1883: 5e0f947 1879: 6837ff6 1871: 35b483e 1855: 5228324
1 parent ac067da commit 820e7b2

2 files changed

Lines changed: 36 additions & 10 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ refs/heads/master: 689bbb466df4b2d5d2483d6edb8ac5c7c7f7c6fa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
6-
refs/heads/pubsub-alpha: fe57e9865b20a4dee394c8042cd9306a20291149
6+
refs/heads/pubsub-alpha: c0842501db691237da0a2f0d4c466dfbe596bad1
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
88
refs/heads/update-datastore: 482954f2c5055231e5b3122ea91d2ba00ce8187c
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

branches/pubsub-alpha/README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,36 @@ Example Applications
3737
- [`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
3838
- 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).
3939

40+
Specifying a Project
41+
--------------------
42+
43+
Most `gcloud-java` libraries require a project ID. There are multiple ways to specify this project ID.
44+
45+
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.
46+
2. When using `gcloud-java` elsewhere, you can do one of the following:
47+
* Supply the project ID when building the service options. For example, to use Datastore from a project with ID "PROJECT_ID", you can write:
48+
49+
```java
50+
Datastore datastore = DatastoreOptions.builder().projectId("PROJECT_ID").build().service();
51+
```
52+
* Specify the environment variable `GCLOUD_PROJECT`. For example, type the following into command line:
53+
54+
```bash
55+
export GCLOUD_PROJECT=PROJECT_ID
56+
```
57+
* 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:
58+
59+
```
60+
gcloud config set project PROJECT_ID
61+
```
62+
63+
`gcloud-java` determines the project ID from the following sources in the listed order, stopping once it finds a value:
64+
65+
1. Project ID supplied when building the service options.
66+
2. Project ID specified by the environment variable `GCLOUD_PROJECT`.
67+
3. Project ID used by App Engine.
68+
4. Project ID specified in the Google Cloud SDK.
69+
4070
Authentication
4171
--------------
4272

@@ -45,15 +75,18 @@ There are multiple ways to authenticate to use Google Cloud services.
4575
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
4676
2. When using `gcloud-java` libraries elsewhere, there are two options:
4777
* [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-
* 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`
78+
* Define the environment variable GOOGLE_APPLICATION_CREDENTIALS to be the location of the key. For example:
79+
```bash
80+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/key.json
81+
```
4982
* 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:
5083
```java
5184
Storage storage = StorageOptions.builder()
5285
.authCredentials(AuthCredentials.createForJson(new FileInputStream("/path/to/my/key.json"))
5386
.build()
5487
.service();
5588
```
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`.
89+
* 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 your current project is set correctly by running `gcloud config set project PROJECT_ID`.
5790
5891
`gcloud-java` looks for credentials in the following order, stopping once it finds credentials:
5992
@@ -63,13 +96,6 @@ There are multiple ways to authenticate to use Google Cloud services.
6396
4. Google Cloud SDK credentials
6497
5. Compute Engine credentials
6598
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. Project ID supplied when building the service options
69-
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
70-
3. App Engine project ID
71-
4. Google Cloud SDK project ID
72-
7399
Google Cloud Datastore
74100
----------------------
75101

0 commit comments

Comments
 (0)