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
Copy file name to clipboardExpand all lines: README.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,22 +48,22 @@ This library supports the maintenance LTS, active LTS, and current release of no
48
48
### Installation
49
49
This library is distributed on `npm`. In order to add it as a dependency, run the following command:
50
50
51
-
```sh
51
+
```sh
52
52
$ npm install googleapis
53
53
```
54
54
55
55
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:
56
56
57
-
```sh
57
+
```sh
58
58
$ npm install @googleapis/docs
59
59
```
60
60
61
-
You can run [this search](https://www.npmjs.com/search?q=scope%3Agoogleapis) on npm, to find a list of the submodules available.
61
+
You can run [this search](https://www.npmjs.com/search?q=scope%3Agoogleapis) on `npm`, to find a list of the submodules available.
62
62
### Using the client library
63
63
64
64
This is a very simple example. This creates a Blogger client and retrieves the details of a blog given the blog Id:
65
65
66
-
```js
66
+
```js
67
67
const {google} =require('googleapis');
68
68
69
69
// Each API may support multiple versions. With this sample, we're getting
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.
206
207
208
+
```
207
209
GET /oauthcallback?code={authorizationCode}
208
-
210
+
```
209
211
#### Retrieve access token
210
212
211
213
With the code returned, you can ask for an access token as shown below:
212
214
213
-
```js
215
+
```js
214
216
// This will provide an object with the access_token and refresh_token.
215
217
// Save these somewhere safe so they can be used at a later time.
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).
236
+
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).
235
237
236
238
To set the `refresh_token` at a later time, you can use the `setCredentials` method:
237
239
@@ -256,7 +258,7 @@ As a developer, you should write your code to handle the case where a refresh to
256
258
### Using API keys
257
259
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:
258
260
259
-
```js
261
+
```js
260
262
const {google} =require('googleapis');
261
263
constblogger=google.blogger_v3({
262
264
version:'v3',
@@ -315,7 +317,7 @@ main().catch(console.error);
315
317
316
318
### Service account credentials
317
319
318
-
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:
320
+
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:
319
321
- Go to the [Create Service Account Key page](https://console.cloud.google.com/apis/credentials/serviceaccountkey)
320
322
- Select `New Service Account` in the drop down
321
323
- Click the `Create` button
@@ -325,7 +327,7 @@ Save the service account credential file somewhere safe, and *do not check this
325
327
#### Using the `GOOGLE_APPLICATION_CREDENTIALS` env var
326
328
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:
@@ -346,7 +348,7 @@ const auth = new google.auth.GoogleAuth({
346
348
347
349
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:
348
350
349
-
```js
351
+
```js
350
352
const {google} =require('googleapis');
351
353
352
354
constoauth2Client=newgoogle.auth.OAuth2(
@@ -363,7 +365,7 @@ google.options({
363
365
364
366
Instead of setting the option globally, you can also set the authentication client at the service-level:
365
367
366
-
```js
368
+
```js
367
369
const {google} =require('googleapis');
368
370
constoauth2Client=newgoogle.auth.OAuth2(
369
371
YOUR_CLIENT_ID,
@@ -401,7 +403,7 @@ This client supports multipart media uploads. The resource parameters are specif
401
403
402
404
This example uploads a plain text file to Google Drive with the title "Test" and contents "Hello World".
Copy file name to clipboardExpand all lines: generator.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Using the Generator
2
-
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.
2
+
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.
3
3
4
4
## Running the generator locally
5
5
To run the generator locally:
@@ -10,43 +10,46 @@ To run the generator locally:
10
10
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.
11
11
12
12
### Generatoring from the cache
13
-
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:
13
+
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:
14
+
14
15
```sh
15
16
npm run generate -- --use-cache
16
17
```
17
18
18
19
### Downloading discovery files
19
-
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:
20
+
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:
21
+
20
22
```sh
21
23
npm run download
22
24
```
23
25
24
26
## Submitting generator PRs
25
-
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:
27
+
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:
26
28
1. Download all discovery files (`npm run download`)
27
29
2. Run the generator (`npm run generate`)
28
30
3. Iterate over each directory in `src/apis`, and create a commit with only those changes
29
31
4. Submit a single PR with multiple commits, including a changelog
30
32
31
33
## Generating individual APIs
32
34
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:
0 commit comments