@@ -10,25 +10,43 @@ write a TimeSeries value to it.
10
10
11
11
* [Maven 3](https://maven.apache.org)
12
12
13
+ # Set Up Your Local Dev Environment
13
14
14
- Go to the [ Google Developers Console ] ( https://console.developer.google.com ) .
15
+ Create local credentials by running the following command and following the oauth2 flow:
15
16
16
- * Go too API Manager -> Credentials
17
- * Click ['New Credentials', and create a Service Account](https://console.developers.google.com/project/_/apiui/credential/serviceaccount)
18
- Download the JSON for this service account, and set the
19
- `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the file
20
- containing the JSON credentials.
17
+ gcloud beta auth application-default login
18
+
19
+ To run:
20
+ * ` mvn clean install `
21
+ * `./list_resources_example.sh <YOUR-PROJECT-ID >
22
+ * `./run_custom_metrics.sh <YOUR-PROJECT-ID >
21
23
22
- ```
23
- export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
24
- ```
24
+ ## Running on GCE, GAE, or other environments
25
25
26
- # Set Up Your Local Dev Environment
26
+ On Google App Engine, the credentials should be found automatically.
27
27
28
- To run locally:
29
- * ` mvn clean install `
30
- * `./list_resources_example.sh <YOUR-PROJECT-ID >
31
- * `./run_custom_metrics.sh <YOUR-PROJECT-ID >
28
+ On Google Compute Engine, the credentials should be found automatically, but require that
29
+ you create the instance with the correct scopes.
30
+
31
+ gcloud compute instances create --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonly" test-instance
32
+
33
+ If you did not create the instance with the right scopes, you can still upload a JSON service
34
+ account and set GOOGLE_APPLICATION_CREDENTIALS as described below.
35
+
36
+ ## Using a Service Account
37
+
38
+ In non-Google Cloud environments, GCE instances created without the correct scopes, or local
39
+ workstations if the ` gcloud beta auth application-default login ` command fails, use a Service
40
+ Account by doing the following:
41
+
42
+ * Go to API Manager -> Credentials
43
+ * Click 'New Credentials', and create a Service Account or [ click here] (https://console.cloud.google
44
+ .com/project/_ /apiui/credential/serviceaccount)
45
+ Download the JSON for this service account, and set the ` GOOGLE_APPLICATION_CREDENTIALS `
46
+ environment variable to point to the file containing the JSON credentials.
47
+
48
+
49
+ export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
32
50
33
51
## Run Tests
34
52
0 commit comments