Visit the Google API Console to obtain OAuth 2.0 credentials such as a client ID and client secret that are known to both Google and your application.
- Credentials > Create credentials > OAuth client ID > Other
- Close the window containing your Client ID and Client Secret
- In the Credentials list, click on the name of the new OAuth 2.0 client ID
- Click
DOWNLOAD JSON
- Open in VS Code, format document
{
"installed": {
"client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"project_id": "dtrt-cv-xxxxxxxxxxxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
}
}
- Method: documents.batchUpdate > Authorization Scopes
- OAuth 2.0 Scopes for Google APIs > Google Docs API, v1
https://www.googleapis.com/auth/documents
- Open Postman.app
- Create a new tab
- Authorization
- OAuth 2.0
- Get New Access Token
- Get New Access Token window opens
- Token Name:
Whatever
- Grant Type:
Authorization Code
- Callback URL:
installed.redirect_uris.1
- Auth URL:
installed.auth_uri
- Access Token URL:
installed.token_uri
- Client ID:
installed.client_id
- Client Secret:
installed.client_secret
- Scope:
scope
- State:
[blank]
- Client Authentication:
Send as Basic Auth header
- Token Name:
- Click
Request Token
- Google will show the Sign In modal
- Enter your Google email address
- Enter your Google password
- If login was successful, Postman will show a window containing the response, and populate the
Access Token
field.
Creates a blank document using the title given in the request. Other fields in the request, including any provided content, are ignored.
POST: https://docs.googleapis.com/v1/documents
Body:
{
"title": "Google Docs API Test 1"
}
Send.
Returns a response object contain various things including the documentId
POST: https://docs.googleapis.com/v1/documents/
documentId
:batchUpdate
Body:
{
"requests": [
{
"insertText": {
"text": "Hello world",
"location": {
"index": 1
}
}
}
]
}
Send.