-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add authorization guide + links to Google docs
- Loading branch information
1 parent
b094aa2
commit ededfe2
Showing
13 changed files
with
130 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script id="authorization-header.html" type="text/ng-template"> | ||
<header header title="Authorization"> | ||
<div class="row row--right"> | ||
<div class="col margin-vertical"> | ||
<a href="https://github.com/GoogleCloudPlatform/gcloud-node/edit/master/docs/authorization.md" | ||
class="v-btn"> | ||
<img src="site/img/icon-link-github.svg" /> | ||
Edit on GitHub | ||
</a> | ||
</div> | ||
</div> | ||
</header> | ||
</script> | ||
|
||
<div subpage | ||
header-templateUrl="authorization-header.html" | ||
title="Authorization"> | ||
<btf-markdown ng-include="'authorization.md'"></btf-markdown> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,13 +44,13 @@ <h3 class="sub-heading"> | |
<div hljs>$ npm install --save gcloud</div> | ||
<div hljs>var gcloud = require('gcloud');</div> | ||
<p> | ||
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. | ||
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. | ||
</p> | ||
<p> | ||
However, if you're running your app elsewhere, you will need to provide project details to authenticate API requests. | ||
</p> | ||
<div hljs> | ||
// App Engine and Compute Engine | ||
// Compute Engine | ||
var gcloud = require('gcloud'); | ||
|
||
// Elsewhere | ||
|
@@ -59,7 +59,7 @@ <h3 class="sub-heading"> | |
keyFilename: '/path/to/keyfile.json' | ||
});</div> | ||
<p> | ||
The full set of options which can be passed to gcloud and sub-modules are <a href="#/docs/?method=gcloud">outlined here</a>. | ||
The full set of options which can be passed to gcloud and sub-modules are <a href="#/authorization">outlined here</a>. | ||
</p> | ||
</article> | ||
<hr> | ||
|
@@ -69,10 +69,8 @@ <h3>BigQuery Overview</h3> | |
<p> | ||
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>. | ||
</p> | ||
<div hljs> | ||
var bigquery = gcloud.bigquery();</div> | ||
<p> | ||
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 <a href="https://cloud.google.com/bigquery/what-is-bigquery">What is BigQuery?</a> | ||
</p> | ||
</article> | ||
|
||
|
@@ -81,13 +79,8 @@ <h3>Datastore Overview</h3> | |
<p> | ||
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. | ||
</p> | ||
<div hljs> | ||
var dataset = gcloud.datastore.dataset({ | ||
projectId: 'project-id', | ||
keyFilename: '/path/to/keyfile.json' | ||
});</div> | ||
<p ng-if="!isActiveUrl('/docs/datastore/dataset')"> | ||
See <a href="#/docs/{{version}}/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others. | ||
<p> | ||
To learn more about Datastore, read the <a href="https://cloud.google.com/datastore/docs/concepts/overview">Google Cloud Datastore Concepts Overview</a>. | ||
</p> | ||
</article> | ||
|
||
|
@@ -97,41 +90,28 @@ <h3>Pub/Sub Overview</h3> | |
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. | ||
</p> | ||
<p> | ||
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 <a href="https://developers.google.com/pubsub/overview">Google Cloud Pub/Sub overview</a> for more information. | ||
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. | ||
</p> | ||
<div hljs> | ||
var pubsub = gcloud.pubsub({ | ||
projectId: 'project-id', | ||
keyFilename: '/path/to/keyfile.json' | ||
});</div> | ||
<p> | ||
See the examples below, which demonstrate everything from creating a topic to subscribing to messages on a topic. | ||
To learn more about Pub/Sub, see the <a href="https://developers.google.com/pubsub/overview">Google Cloud Pub/Sub overview</a>. | ||
</p> | ||
</article> | ||
|
||
<article ng-if="isActiveDoc('storage')"> | ||
<h3>Storage Overview</h3> | ||
<p> | ||
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 <a href="https://developers.google.com/storage">Google Cloud Storage</a> to create a bucket. | ||
The <code>gcloud.storage</code> object contains a <code>bucket</code> function, which is how you will interact with your Google Cloud Storage bucket. | ||
</p> | ||
<div hljs> | ||
var bucket = gcloud.storage.bucket('my-bucket');</div> | ||
<h4>ACLs</h4> | ||
<p> | ||
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. | ||
To learn more about Cloud Storage, see the <a href="https://cloud.google.com/storage/docs/overview">Google Cloud Storage overview</a>. | ||
</p> | ||
|
||
<h4>ACLs</h4> | ||
<p> | ||
Convenience methods are provided to perform common operations, such as the following. | ||
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. | ||
</p> | ||
<div hljs> | ||
// Allow a user to read files from a bucket. | ||
bucket.acl.readers.addUser('[email protected]', function(err, aclObject) {}); | ||
|
||
// Revoke file ownership permissions from a group. | ||
var myFile = bucket.file('my-file.txt'); | ||
myFile.acl.owners.deleteGroup('group-id', function(err, aclObject) {});</div> | ||
<p> | ||
See examples below for more on how to access your bucket to upload a file, read its files, create signed URLs, and more. | ||
To learn more about ACLs, read this overview on <a href="https://cloud.google.com/storage/docs/access-control">Access Control</a>. | ||
</p> | ||
</article> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.