Application Configuration and Access Token Generation for Dynamic OAuth2 Account
In this Article
Overview
Snaps in the Google Spreadsheet Snap Pack use the Spreadsheet Dynamic OAuth2 account to access the Google application. For the 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
Log into your Google Cloud Platform Console.
In the left navigation pane, navigate to APIs & Services > Library.
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.
Click NEW PROJECT to create a new project.
In the left navigation pane, navigate to APIs & Services > OAuth consent screen.
In the OAuth consent screen, provide App information, App domain, Scopes and click Save.
In the left navigation pane, navigate to Credentials > +CREATE CREDENTIALS > OAuth client ID.
In the Application type list, select Web application.
Under Authorized redirect URIs, click +ADD URI and add the URIs.
Click Create. Upon redirecting your Client ID and Client Secret are generated.
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.
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.comThe 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.
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
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:
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.
The access token that is generated expires in one hour.
Related Links:
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.