Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel5

Overview

Snaps in the Google Spreadsheet Snap Pack use the Spreadsheet Dynamic OAuth2 account to access the Google application. For the OAuth2 account to function without any issue, ensure to create and configure an application corresponding to the account as explained in the steps below. These steps also contain the information required to create/define a new Dynamic OAuth2 account for using this Snap Pack.

Configuring an app for your project

  1. Log into your Google Cloud Platform Console.

  2. In the left navigation pane, navigate to APIs & Services > Library.

    Image Modified
  3. In the API Library page, you can either select an existing project or create a new project. In this article, we describe the procedure for creating a new project.

  4. Click NEW PROJECT to create a new project.

    Image Modified
  5. In the left navigation pane, navigate to APIs & Services > OAuth consent screen.

    Image Modified
  6. In the OAuth consent screen, provide App information, App domain, Scopes and click Save.

    Image Modified
  7. In the left navigation pane, navigate to Credentials > +CREATE CREDENTIALS > OAuth client ID.

    Image Modified
  8. In the Application type list, select Web application.

    Image Modified
  9. Under Authorized redirect URIs, click +ADD URI and add the URIs.

    Image Modified
  10. Click Create. Upon redirecting your Client ID and Client Secret are generated.

    Image Modified

You can download the JSON file containing your Client ID and Client Secret and save it.

Obtaining OAuth 2.0 Access Token to use in Spreadsheet Dynamic OAuth2 Account

Before your application can access data using a Google API, it must obtain an Access Token that grants access to that API.

  1. To obtain an Access Token, enter the https://accounts.google.com/o/oauth2/v2/auth? URI in Google Chrome browser to get an authorization code.
    scope=https://www.googleapis.com/auth/drive&
    access_type=offline&
    include_granted_scopes=true&
    response_type=code&
    redirect_uri=https://canary.elastic.snaplogic.com&
    client_id=445703106862-v037fu6esgg3t231trc722qsig3v8965.apps.googleusercontent.com

  2. The Google's OAuth 2.0 server authenticates the user and obtains consent from you for your application to access the requested scopes; you can then decide whether to grant your application the requested access.

  3. If you approve the access request, then the response that is returned contains an authorization code response as shown below:
    https://www.google.com/?code=4/3wHPSXTPrE6KTzHJmiAOLw8maDO6ynOrQ0MOGeZgipL_m1nMIsMAa_7amGhzDMR2o2RADq3DpJCZ36Y82ApadQE&scope=https://www.googleapis.com/auth/spreadsheets

  4. Copy the code from the given URI and click Save.

...

Exchange authorization code for refresh and access tokens

To exchange an authorization code for an access token:

  1. Call the https://oauth2.googleapis.com/token endpoint and set the following parameters using Postman REST Post:

    https://oauth2.googleapis.com/token?

    client_id=445703106862-22kvtftg26t2gv0h9ide22saadmh35gp.apps.googleusercontent.com&

    client_secret=m7RR91Dg-CiMXGI0a7hzg5Aj&

    code=4/3wGVg78nKxConwa0RlywkfE-yZw0An9GvKqmoTPFb-6lS6bqU4mQVyDBV9AFazcQMSTsgJofy0Ut7DHQHvK1Vi0&

    grant_type=authorization_code

    redirect_uri=https://snap.elastic.snaplogic.com

...

The URI looks like: https://oauth2.googleapis.com/token?client_id=445703106862-22kvtftg26t2gv0h9ide22saadmh35gp.apps.googleusercontent.com&client_secret=m7RR91Dg-CiMXGI0a7hzg5Aj&code=4/3wGVg78nKxConwa0RlywkfE-yZw0An9GvKqmoTPFb-6lS6bqU4mQVyDBV9AFazcQMSTsgJofy0Ut7DHQHvK1Vi0&grant_type=authorization_code&redirect_uri=https://snap.elastic.snaplogic.com

2. Use the obtained access token in creating the Spreadsheet Dynamic OAuth2 account.

...