Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fixed typos and spaces #3464

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions CONTRIBUTING.md
Expand Up @@ -50,22 +50,26 @@ accept your pull requests.

1. Install dependencies:

npm install

```sh
npm install
```
1. Run the tests:

# Run unit tests.
npm test

# Run sample integration tests.
npm run samples-test
```sh
# Run unit tests.
npm test

# Run all system tests.
npm run system-test
# Run sample integration tests.
npm run samples-test

# Run all system tests.
npm run system-test
```
1. Lint (and maybe fix) any changes:

npm run fix
```sh
npm run fix
```

[setup]: https://cloud.google.com/nodejs/docs/setup
[projects]: https://console.cloud.google.com/project
Expand Down
38 changes: 20 additions & 18 deletions README.md
Expand Up @@ -48,22 +48,22 @@ This library supports the maintenance LTS, active LTS, and current release of no
### Installation
This library is distributed on `npm`. In order to add it as a dependency, run the following command:

``` sh
```sh
$ npm install googleapis
```

If you need to reduce startup times, you can alternatively install a submodule as its own dependency. We make an effort to publish submodules that are __not__ in this [list](https://github.com/googleapis/google-cloud-node#google-cloud-nodejs-client-libraries). In order to add it as a dependency, run the following sample command, replacing with your preferred API:

``` sh
```sh
$ npm install @googleapis/docs
```

You can run [this search](https://www.npmjs.com/search?q=scope%3Agoogleapis) on npm, to find a list of the submodules available.
You can run [this search](https://www.npmjs.com/search?q=scope%3Agoogleapis) on `npm`, to find a list of the submodules available.
### Using the client library

This is a very simple example. This creates a Blogger client and retrieves the details of a blog given the blog Id:

``` js
```js
const {google} = require('googleapis');

// Each API may support multiple versions. With this sample, we're getting
Expand All @@ -89,7 +89,7 @@ blogger.blogs.get(params, (err, res) => {

Instead of using callbacks you can also use promises!

``` js
```js
blogger.blogs.get(params)
.then(res => {
console.log(`The blog url is ${res.data.url}`);
Expand All @@ -101,17 +101,18 @@ blogger.blogs.get(params)

Or async/await:

``` js
```js
async function runSample() {
const res = await blogger.blogs.get(params);
console.log(`The blog url is ${res.data.url}`);
}

runSample().catch(console.error);
```

Alternatively, you can make calls directly to the APIs by installing a submodule:

``` js
```js
const docs = require('@googleapis/docs')

const auth = new docs.auth.GoogleAuth({
Expand Down Expand Up @@ -174,7 +175,7 @@ A complete sample application that authorizes and authenticates with the OAuth2

To ask for permissions from a user to retrieve an access token, you redirect them to a consent page. To create a consent page URL:

``` js
```js
const {google} = require('googleapis');

const oauth2Client = new google.auth.OAuth2(
Expand All @@ -193,7 +194,7 @@ const url = oauth2Client.generateAuthUrl({
// 'online' (default) or 'offline' (gets refresh_token)
access_type: 'offline',

// If you only need one scope you can pass it as a string
// If you only need one scope, you can pass it as a string
scope: scopes
});
```
Expand All @@ -204,13 +205,14 @@ const url = oauth2Client.generateAuthUrl({

Once a user has given permissions on the consent page, Google will redirect the page to the redirect URL you have provided with a code query parameter.

```
GET /oauthcallback?code={authorizationCode}

```
#### Retrieve access token

With the code returned, you can ask for an access token as shown below:

``` js
```js
// This will provide an object with the access_token and refresh_token.
// Save these somewhere safe so they can be used at a later time.
const {tokens} = await oauth2Client.getToken(code)
Expand All @@ -231,7 +233,7 @@ oauth2Client.on('tokens', (tokens) => {
console.log(tokens.access_token);
});
```
This tokens event only occurs in the first authorization, and you need to have set your `access_type` to `offline` when calling the `generateAuthUrl` method to receive the refresh token. If you have already given your app the requisiste permissions without setting the appropriate constraints for receiving a refresh token, you will need to re-authorize the application to receive a fresh refresh token. You can revoke your app's access to your account [here](https://myaccount.google.com/permissions).
This tokens event only occurs in the first authorization, and you need to have set your `access_type` to `offline` when calling the `generateAuthUrl` method to receive the refresh token. If you have already given your app the requisite permissions without setting the appropriate constraints for receiving a refresh token, you will need to re-authorize the application to receive a fresh refresh token. You can revoke your app's access to your account [here](https://myaccount.google.com/permissions).

To set the `refresh_token` at a later time, you can use the `setCredentials` method:

Expand All @@ -256,7 +258,7 @@ As a developer, you should write your code to handle the case where a refresh to
### Using API keys
You may need to send an API key with the request you are going to make. The following uses an API key to make a request to the Blogger API service to retrieve a blog's name, url, and its total amount of posts:

``` js
```js
const {google} = require('googleapis');
const blogger = google.blogger_v3({
version: 'v3',
Expand Down Expand Up @@ -315,7 +317,7 @@ main().catch(console.error);

### Service account credentials

Service accounts allow you to perform server to server, app-level authentication using a robot account. You will create a service account, download a keyfile, and use that to authenticate to Google APIs. To create a service account:
Service accounts allow you to perform server-to-server, app-level authentication using a robot account. You will create a service account, download a keyfile, and use that to authenticate to Google APIs. To create a service account:
- Go to the [Create Service Account Key page](https://console.cloud.google.com/apis/credentials/serviceaccountkey)
- Select `New Service Account` in the drop down
- Click the `Create` button
Expand All @@ -325,7 +327,7 @@ Save the service account credential file somewhere safe, and *do not check this
#### Using the `GOOGLE_APPLICATION_CREDENTIALS` env var
You can start process with an environment variable named `GOOGLE_APPLICATION_CREDENTIALS`. The value of this env var should be the full path to the service account credential file:

```
```sh
$ GOOGLE_APPLICATION_CREDENTIALS=./your-secret-key.json node server.js
```

Expand All @@ -346,7 +348,7 @@ const auth = new google.auth.GoogleAuth({

You can set the `auth` as a global or service-level option so you don't need to specify it every request. For example, you can set `auth` as a global option:

``` js
```js
const {google} = require('googleapis');

const oauth2Client = new google.auth.OAuth2(
Expand All @@ -363,7 +365,7 @@ google.options({

Instead of setting the option globally, you can also set the authentication client at the service-level:

``` js
```js
const {google} = require('googleapis');
const oauth2Client = new google.auth.OAuth2(
YOUR_CLIENT_ID,
Expand Down Expand Up @@ -401,7 +403,7 @@ This client supports multipart media uploads. The resource parameters are specif

This example uploads a plain text file to Google Drive with the title "Test" and contents "Hello World".

``` js
```js
const drive = google.drive({
version: 'v3',
auth: oauth2Client
Expand Down
21 changes: 12 additions & 9 deletions generator.md
@@ -1,5 +1,5 @@
# Using the Generator
The clients in this repository are all automatically generated. They are generated using the [Google Discovery Service](https://developers.google.com/discovery). Most users of this library will not need to directly use the generator. This documentation is intended for users that need to maintain the repository, or build custom clients.
The clients in this repository are all automatically generated. They are generated using the [Google Discovery Service](https://developers.google.com/discovery). Most users of this library will not need to directly use the generator. This documentation is intended for users that need to maintain the repository, or build custom clients.

## Running the generator locally
To run the generator locally:
Expand All @@ -10,43 +10,46 @@ To run the generator locally:
This command will download all discovery files available via the [discovery index](https://www.googleapis.com/discovery/v1/apis/), and run the code generator against those files.

### Generatoring from the cache
There are some situations where you don't want to re-download the discovery files before running the generator. This is particularly useful in situations where you're working on the generator itself, and want to isolate the change. To prevent the generator from re-downloading the discovery files, run:
There are some situations where you don't want to re-download the discovery files before running the generator. This is particularly useful in situations where you're working on the generator itself, and want to isolate the change. To prevent the generator from re-downloading the discovery files, run:

```sh
npm run generate -- --use-cache
```

### Downloading discovery files
As part of the `npm run generate` command, discovery docs are downloaded. To only download discovery file updates, and not re-run the generator, run:
As part of the `npm run generate` command, discovery docs are downloaded. To only download discovery file updates, and not re-run the generator, run:

```sh
npm run download
```

## Submitting generator PRs
This repository uses [synthtool](https://github.com/googleapis/synthtool/) to re-generate the API on a nightly basis. The command `npm run submit-prs` will perform a variety of steps:
This repository uses [synthtool](https://github.com/googleapis/synthtool/) to re-generate the API on a nightly basis. The command `npm run submit-prs` will perform a variety of steps:
1. Download all discovery files (`npm run download`)
2. Run the generator (`npm run generate`)
3. Iterate over each directory in `src/apis`, and create a commit with only those changes
4. Submit a single PR with multiple commits, including a changelog

## Generating individual APIs
You can generate a single API based on a discovery URL. Replace the url and API name below to match the API you'd like to generate:
```

```sh
npm run build-tools
node build/src/generator/generator.js 'https://apigee.googleapis.com/$discovery/rest?version=v1' \
--include-private false \
--use-cache false
```

Assuming that command completes successfully, you can access the output and test it out by navigating to the API subdirectory:
```

```sh
cd src/apis/apigee
npm install
```



If you want to distribute this package, which is common for APIs not listed in the discovery index, you can pack it to generate a tarball:
```

```sh
npm pack
```

Expand Down
4 changes: 3 additions & 1 deletion samples/analytics/README.md
Expand Up @@ -6,4 +6,6 @@ The Google Analytics API lets you collect, configure, and analyze your data to r

## Running the sample

`node analytics.js`
```sh
node analytics.js
```
4 changes: 3 additions & 1 deletion samples/blogger/README.md
Expand Up @@ -6,4 +6,6 @@ The Blogger API v3 allows client applications to view and update Blogger content

## Running the sample

`node blogger.js`
```sh
node blogger.js
```
4 changes: 3 additions & 1 deletion samples/compute/README.md
Expand Up @@ -6,4 +6,6 @@ The Google Compute Engine Metadata service lets you get and set key/value pairs

## Running the sample

`node listVMs.js`
```sh
node listVMs.js
```
4 changes: 3 additions & 1 deletion samples/customsearch/README.md
Expand Up @@ -6,4 +6,6 @@ Google Custom Search enables you to create a search engine for your website, you

## Running the sample

`node customsearch.js`
```sh
node customsearch.js
```
4 changes: 2 additions & 2 deletions samples/defaultauth.js
Expand Up @@ -17,7 +17,7 @@ const {google} = require('googleapis');
const compute = google.compute('v1');

/**
* The google.auth.getClient method creates the appropriate type of credential client for you,
* The `google.auth.getClient` method creates the appropriate type of credential client for you,
* depending upon whether the client is running in Google App Engine, Google Compute Engine, a
* Managed VM, or on a local developer machine. This allows you to write one set of auth code that
* will work in all cases. It most situations, it is advisable to use the getClient method rather
Expand All @@ -27,7 +27,7 @@ const compute = google.compute('v1');
* file to your machine, and to set a local environment variable pointing to the location of the
* file. Create a service account using the Google Developers Console using the section APIs & Auth.
* Select "Generate new JSON key" and download the resulting file. Once this is done, set the
* GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the location of the .json file.
* `GOOGLE_APPLICATION_CREDENTIALS` environment variable to point to the location of the .json file.
*
* See also:
* https://developers.google.com/accounts/docs/application-default-credentials
Expand Down
10 changes: 5 additions & 5 deletions samples/drive/README.md
Expand Up @@ -34,36 +34,36 @@ You'll need to do the following before you can run this sample:
* Enable the [Google Drive API](https://console.developers.google.com/apis/api/drive.googleapis.com/overview).
* Set the redirect API in the Google Cloud Console application registration to `http://localhost:3000/oauth2callback`.

```
```sh
node quickstart.js
```

__Run the `download.js` sample:__

Run the `quickstart.js` sample to get a list of files in your Google Drive.

```
```sh
node download.js <fileId>
```

where `<fileId>` is the id of any file in Google Drive.

Example:

```
```sh
node download.js 0B_Klegupc5gUcXhFZjZVUV9NeE0
```

__Run the `export.js` sample:__

```
```sh
node export.js <fileId>=
```

where `<fileId>` is the id of a _Google Doc_ in Google Drive.

Example:

```
```sh
node export.js 0B_Klegupc5gUcXhFZjZVUV9NeE0 ./file.pdf
```
8 changes: 5 additions & 3 deletions samples/gmail/watch.js
Expand Up @@ -21,10 +21,12 @@ const gmail = google.gmail('v1');

/**
* NOTE: Before using this API, you need to do a few things.
* 1. Create a new Pub/Sub topic. You can use the command:
* gcloud pubsub topics create gmail
* 1. Create a new Pub/Sub topic. You can use the command:
* ```sh
* $ gcloud pubsub topics create gmail
* ```
* 2. Go to the Cloud Developer Console, and give the gmail
* service account gmail-api-push@system.gserviceaccount.com
* service account `gmail-api-push@system.gserviceaccount.com`
* Pub/Sub Publisher rights to your newly created topic.
* https://console.cloud.google.com/cloudpubsub/topicList?project=${PROJECT_NAME}
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/jwt.js
Expand Up @@ -23,7 +23,7 @@ const path = require('path');
* Suggested reading for Admin SDK users using service accounts:
* https://developers.google.com/admin-sdk/directory/v1/guides/delegation
*
* See the defaultauth.js sample for an alternate way of fetching compute credentials.
* See the `defaultauth.js` sample for an alternate way of fetching compute credentials.
*/
async function runSample() {
// Create a new JWT client using the key file downloaded from the Google Developer Console
Expand Down
6 changes: 4 additions & 2 deletions samples/mirror/README.md
Expand Up @@ -6,6 +6,8 @@ The Google Mirror API allows you to build web-based services that interact with

## Running the sample

To run this sample, add your client id, client secret, and redirect url in oauth2.keys.json. You can also download this file directly from the Google Developers console. Then run:
To run this sample, add your client id, client secret, and redirect url in `oauth2.keys.json`. You can also download this file directly from the Google Developers console. Then run:

`node mirror.js`
```sh
node mirror.js
```