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
With `gcloud-node` it's incredibly easy to get authorized and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Google Cloud services.
2
+
3
+
## On Google Compute Engine
4
+
5
+
If you are running this client on Google Compute Engine, we handle authorization for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
6
+
7
+
```js
8
+
var config = {
9
+
projectId:'grape-spaceship-123'
10
+
};
11
+
12
+
var gcloud =require('gcloud')(config);
13
+
```
14
+
15
+
## Elsewhere
16
+
17
+
If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account:
18
+
19
+
1. Visit the [Google Developers Console][dev-console].
20
+
2. Create a new project or click on an existing project.
21
+
3. Navigate to **APIs & auth** > **APIs section** and turn on the following APIs (you may need to enable billing in order to use these services):
22
+
* Google Cloud Datastore API
23
+
* Google Cloud Storage
24
+
* Google Cloud Storage JSON API
25
+
4. Navigate to **APIs & auth** > **Credentials** and then:
26
+
* If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authorize your requests.
27
+
* If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
28
+
29
+
```js
30
+
var config = {
31
+
projectId:'grape-spaceship-123',
32
+
keyFilename:'/path/to/keyfile.json'
33
+
};
34
+
35
+
var gcloud =require('gcloud')(config);
36
+
```
37
+
38
+
### The `config` object
39
+
40
+
A `config` object requires the following properties:
41
+
42
+
1.`projectId`
43
+
44
+
2. One of the following:
45
+
1.`config.credentials` object containing `client_email` and `private_key` properties.
46
+
2.`config.keyFilename` path to a .json, .pem, or .p12 key file.
47
+
3.`GOOGLE_APPLICATION_CREDENTIALS` environment variable with a full path to your key file.
48
+
49
+
**Note**: When using a .pem or .p12 key file, `config.email` is also required.
Copy file name to clipboardExpand all lines: docs/site/components/docs/docs.html
+14-34
Original file line number
Diff line number
Diff line change
@@ -44,13 +44,13 @@ <h3 class="sub-heading">
44
44
<divhljs>$ npm install --save gcloud</div>
45
45
<divhljs>var gcloud = require('gcloud');</div>
46
46
<p>
47
-
If you are running your app on Google App Engine or Google Compute Engine, you won't need to worry about supplying connection configuration options to <code>gcloud</code>— we figure that out for you.
47
+
If you are running your app on Google Compute Engine, you won't need to worry about supplying connection configuration options to <code>gcloud</code>— we figure that out for you.
48
48
</p>
49
49
<p>
50
50
However, if you're running your app elsewhere, you will need to provide project details to authenticate API requests.
51
51
</p>
52
52
<divhljs>
53
-
// App Engine and Compute Engine
53
+
// Compute Engine
54
54
var gcloud = require('gcloud');
55
55
56
56
// Elsewhere
@@ -59,7 +59,7 @@ <h3 class="sub-heading">
59
59
keyFilename: '/path/to/keyfile.json'
60
60
});</div>
61
61
<p>
62
-
The full set of options which can be passed to gcloud and sub-modules are <ahref="#/docs/?method=gcloud">outlined here</a>.
62
+
The full set of options which can be passed to gcloud and sub-modules are <ahref="#/authorization">outlined here</a>.
63
63
</p>
64
64
</article>
65
65
<hr>
@@ -69,10 +69,8 @@ <h3>BigQuery Overview</h3>
69
69
<p>
70
70
The object returned from <code>gcloud.bigquery</code> gives you complete access to and control of your BigQuery datasets. You can work with existing ones, by using the <code>dataset</code> method, or create new ones with <code>createDataset</code>.
71
71
</p>
72
-
<divhljs>
73
-
var bigquery = gcloud.bigquery();</div>
74
72
<p>
75
-
Follow along with the examples below to see how to query your datasets, create tables, import data from your Cloud Storage buckets, and more.
73
+
To learn more about BigQuery, see <ahref="https://cloud.google.com/bigquery/what-is-bigquery">What is BigQuery?</a>
76
74
</p>
77
75
</article>
78
76
@@ -81,13 +79,8 @@ <h3>Datastore Overview</h3>
81
79
<p>
82
80
The <code>gcloud.datastore</code> object gives you some convenience methods, as well as exposes a <code>dataset</code> function. This will allow you to create a <code>dataset</code>, which is the object from which you will interact with the Google Cloud Datastore.
See <ahref="#/docs/{{version}}/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
82
+
<p>
83
+
To learn more about Datastore, read the <ahref="https://cloud.google.com/datastore/docs/concepts/overview">Google Cloud Datastore Concepts Overview</a>.
91
84
</p>
92
85
</article>
93
86
@@ -97,41 +90,28 @@ <h3>Pub/Sub Overview</h3>
97
90
Google Cloud Pub/Sub is in Alpha status. As a result, it might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.
98
91
</p>
99
92
<p>
100
-
The <code>gcloud.pubsub</code> method will return a <code>pubsub</code> object, allowing you to create topics, publish messages, subscribe to topics, and more. See the <ahref="https://developers.google.com/pubsub/overview">Google Cloud Pub/Sub overview</a> for more information.
93
+
The <code>gcloud.pubsub</code> method will return a <code>pubsub</code> object, allowing you to create topics, publish messages, subscribe to topics, and more.
101
94
</p>
102
-
<divhljs>
103
-
var pubsub = gcloud.pubsub({
104
-
projectId: 'project-id',
105
-
keyFilename: '/path/to/keyfile.json'
106
-
});</div>
107
95
<p>
108
-
See the examples below, which demonstrate everything from creating a topic to subscribing to messages on a topic.
96
+
To learn more about Pub/Sub, see the <ahref="https://developers.google.com/pubsub/overview">Google Cloud Pub/Sub overview</a>.
109
97
</p>
110
98
</article>
111
99
112
100
<articleng-if="isActiveDoc('storage')">
113
101
<h3>Storage Overview</h3>
114
102
<p>
115
-
The <code>gcloud.storage</code> object contains a <code>bucket</code> function, which is how you will interact with your Google Cloud Storage bucket. See the guide on <ahref="https://developers.google.com/storage">Google Cloud Storage</a> to create a bucket.
103
+
The <code>gcloud.storage</code> object contains a <code>bucket</code> function, which is how you will interact with your Google Cloud Storage bucket.
116
104
</p>
117
-
<divhljs>
118
-
var bucket = gcloud.storage().bucket('my-bucket');</div>
119
-
<h4>ACLs</h4>
120
105
<p>
121
-
Google Cloud Storage uses access control lists (ACLs) to manage object and bucket access. ACLs are the mechanism you use to share files with other users and allow other users to access your buckets and files.
106
+
To learn more about Cloud Storage, see the <ahref="https://cloud.google.com/storage/docs/overview">Google Cloud Storage overview</a>.
122
107
</p>
108
+
109
+
<h4>ACLs</h4>
123
110
<p>
124
-
Convenience methods are provided to perform common operations, such as the following.
111
+
Google Cloud Storage uses access control lists (ACLs) to manage object and bucket access. ACLs are the mechanism you use to share files with other users and allow other users to access your buckets and files.
0 commit comments