@@ -14,28 +14,52 @@ value to it.
14
14
15
15
Go to the [ Google Cloud Console] ( https://console.cloud.google.com ) .
16
16
17
- * Go to API Manager -> Credentials
18
- * Click 'New Credentials', and create a Service Account or [ click here] (https://console.cloud.google
19
- .com/project/_ /apiui/credential/serviceaccount)
20
- Download the JSON for this service account, and set the ` GOOGLE_APPLICATION_CREDENTIALS `
21
- environment variable to point to the file containing the JSON credentials.
22
-
23
-
24
- export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
25
-
26
17
27
18
# Set Up Your Local Dev Environment
28
19
To install, run the following commands. If you want to use [ virtualenv] ( https://virtualenv.readthedocs.org/en/latest/ )
29
20
(recommended), run the commands within a virtualenv.
30
21
31
22
* pip install -r requirements.txt
32
23
33
- To run locally:
24
+ Create local credentials by running the following command and following the oauth2 flow:
25
+
26
+ gcloud beta auth application-default login
27
+
28
+ To run:
34
29
35
30
python list_resources.py --project_id=<YOUR-PROJECT-ID>
36
31
python custom_metric.py --project_id=<YOUR-PROJECT-ID
37
32
38
33
34
+ ## Running on GCE, GAE, or other environments
35
+
36
+ On Google App Engine, the credentials should be found automatically.
37
+
38
+ On Google Compute Engine, the credentials should be found automatically, but require that
39
+ you create the instance with the correct scopes.
40
+
41
+ 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
42
+
43
+ If you did not create the instance with the right scopes, you can still upload a JSON service
44
+ account and set GOOGLE_APPLICATION_CREDENTIALS as described below.
45
+
46
+
47
+ ## Using a Service Account
48
+
49
+ In non-Google Cloud environments, GCE instances created without the correct scopes, or local
50
+ workstations if the ` gcloud beta auth application-default login ` command fails, use a Service
51
+ Account by doing the following:
52
+
53
+ * Go to API Manager -> Credentials
54
+ * Click 'New Credentials', and create a Service Account or [ click here] (https://console.cloud.google
55
+ .com/project/_ /apiui/credential/serviceaccount)
56
+ Download the JSON for this service account, and set the ` GOOGLE_APPLICATION_CREDENTIALS `
57
+ environment variable to point to the file containing the JSON credentials.
58
+
59
+
60
+ export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/<project-id>-0123456789abcdef.json
61
+
62
+
39
63
## Contributing changes
40
64
41
65
* See [ CONTRIBUTING.md] ( CONTRIBUTING.md )
0 commit comments