Date: Tue, 21 Apr 2015 12:19:41 -0400
Subject: [PATCH] add authorization guide + links to Google docs
fixes #483
fixes #479
---
docs/authorization.md | 51 +++++++++++++++++++
docs/index.html | 1 +
.../authorization/authorization.html | 19 +++++++
.../components/authorization/authorization.js | 15 ++++++
docs/site/components/docs/docs.html | 48 +++++------------
docs/site/components/subpage/subpage.html | 5 ++
docs/site/home.js | 1 +
lib/bigquery/index.js | 24 +++------
lib/datastore/dataset.js | 12 ++---
lib/datastore/index.js | 20 ++------
lib/index.js | 41 +--------------
lib/pubsub/index.js | 25 +--------
lib/storage/index.js | 19 ++-----
13 files changed, 130 insertions(+), 151 deletions(-)
create mode 100644 docs/authorization.md
create mode 100644 docs/site/components/authorization/authorization.html
create mode 100644 docs/site/components/authorization/authorization.js
diff --git a/docs/authorization.md b/docs/authorization.md
new file mode 100644
index 00000000000..6662d73d55d
--- /dev/null
+++ b/docs/authorization.md
@@ -0,0 +1,51 @@
+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.
+
+## On Google Compute Engine
+
+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.
+
+``` js
+var config = {
+ projectId: 'grape-spaceship-123'
+};
+
+var gcloud = require('gcloud')(config);
+```
+
+## Elsewhere
+
+If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account:
+
+1. Visit the [Google Developers Console][dev-console].
+2. Create a new project or click on an existing project.
+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):
+ * Google Cloud Datastore API
+ * Google Cloud Storage
+ * Google Cloud Storage JSON API
+4. Navigate to **APIs & auth** > **Credentials** and then:
+ * 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.
+ * 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.
+
+``` js
+var config = {
+ projectId: 'grape-spaceship-123',
+ keyFilename: '/path/to/keyfile.json'
+};
+
+var gcloud = require('gcloud')(config);
+```
+
+### The `config` object
+
+A `config` object requires the following properties:
+
+1. `projectId`
+
+2. One of the following:
+ 1. `config.credentials` object containing `client_email` and `private_key` properties.
+ 2. `config.keyFilename` path to a .json, .pem, or .p12 key file.
+ 3. `GOOGLE_APPLICATION_CREDENTIALS` environment variable with a full path to your key file.
+
+**Note**: When using a .pem or .p12 key file, `config.email` is also required.
+
+[dev-console]: https://console.developers.google.com/project
diff --git a/docs/index.html b/docs/index.html
index 9b132a88448..ee051906ad6 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -36,6 +36,7 @@
+
diff --git a/docs/site/components/authorization/authorization.html b/docs/site/components/authorization/authorization.html
new file mode 100644
index 00000000000..a494ccf1c77
--- /dev/null
+++ b/docs/site/components/authorization/authorization.html
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/site/components/authorization/authorization.js b/docs/site/components/authorization/authorization.js
new file mode 100644
index 00000000000..2a108ffa0d7
--- /dev/null
+++ b/docs/site/components/authorization/authorization.js
@@ -0,0 +1,15 @@
+angular
+ .module('gcloud.authorization', ['ngRoute', 'gcloud.subpage', 'btford.markdown'])
+ .config(function($routeProvider) {
+ 'use strict';
+
+ $routeProvider.when('/authorization', {
+ controller: 'AuthorizationCtrl',
+ templateUrl: 'site/components/authorization/authorization.html'
+ });
+ })
+
+ .controller('AuthorizationCtrl', function($scope) {
+ 'use strict';
+
+ });
diff --git a/docs/site/components/docs/docs.html b/docs/site/components/docs/docs.html
index 86264557d39..6be7fb5ac4c 100644
--- a/docs/site/components/docs/docs.html
+++ b/docs/site/components/docs/docs.html
@@ -44,13 +44,13 @@
$ npm install --save gcloud
var gcloud = require('gcloud');
- 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 gcloud
— we figure that out for you.
+ If you are running your app on Google Compute Engine, you won't need to worry about supplying connection configuration options to gcloud
— we figure that out for you.
However, if you're running your app elsewhere, you will need to provide project details to authenticate API requests.
-// App Engine and Compute Engine
+// Compute Engine
var gcloud = require('gcloud');
// Elsewhere
@@ -59,7 +59,7 @@
keyFilename: '/path/to/keyfile.json'
});
- The full set of options which can be passed to gcloud and sub-modules are outlined here.
+ The full set of options which can be passed to gcloud and sub-modules are outlined here.
@@ -69,10 +69,8 @@ BigQuery Overview
The object returned from gcloud.bigquery
gives you complete access to and control of your BigQuery datasets. You can work with existing ones, by using the dataset
method, or create new ones with createDataset
.
-
-var bigquery = gcloud.bigquery();
- Follow along with the examples below to see how to query your datasets, create tables, import data from your Cloud Storage buckets, and more.
+ To learn more about BigQuery, see What is BigQuery?
@@ -81,13 +79,8 @@ Datastore Overview
The gcloud.datastore
object gives you some convenience methods, as well as exposes a dataset
function. This will allow you to create a dataset
, which is the object from which you will interact with the Google Cloud Datastore.
-
-var dataset = gcloud.datastore.dataset({
- projectId: 'project-id',
- keyFilename: '/path/to/keyfile.json'
-});
-
- See the Dataset documentation for examples of how to query the datastore, save entities, run a transaction, and others.
+
+ To learn more about Datastore, read the Google Cloud Datastore Concepts Overview.
@@ -97,41 +90,28 @@ Pub/Sub Overview
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.