Obtaining an access token for Google Drive - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

To use Google Drive APIs, you need first to obtain the access token by completing the following steps using Google Chrome with the REST Console extension installed:

  1. Go to the Google Developers Console and select an existing project or create a new one. In this example, we create a new project TalendProject.

  2. Select the newly created project, click APIs under APIs & auth and enable both the Drive API and Drive SDK APIs by setting their status to ON.

  3. Click Consent screen under APIs & auth and create a new product. In this example, it is TalendProduct.

  4. Click Credentials under APIs & auth, create a new client ID with APPLICATION TYPE set as Installed application and INSTALLED APPLICATION TYPE set as Other.

    The created CLIENT ID, CLIENT SECRET, and REDIRECT URIS will be used for obtaining the access token.

  5. Generate the authentication code by performing an HTTP GET request using a web browser. To do this, copy and paste the request URL https://accounts.google.com/o/oauth2/auth with the following query string parameters into your web browser's address bar, press Enter and accept the access request.

    • client_id: the value of CLIENT ID from the Credentials view.

    • redirect_uri: the value of REDIRECT URIS from the Credentials view.

    • response_type: the value is code.

    • scope: the range of permissions you request users to authorize for your app. For more information, see https://developers.google.com/drive/web/scopes.

    • access_type: the value is online.

    Note that the request URL and the query string parameters are concatenated with a question mark ?, and every two query string parameters are concatenated with an ampersand &. An example URL is shown below, with line breaks for readability. You need to join all these lines into one line before copying and pasting the URL into your web browser's address bar. The scope used in this example has full, permissive scope to access all of the user's files. Request this scope only when it is strictly necessary.

    https://accounts.google.com/o/oauth2/auth?
    client_id=1061335238805-gmctuidvid0lsrdf66nvit0g7j5gnrck.apps.googleusercontent.com&
    redirect_uri=urn:ietf:wg:oauth:2.0:oob&
    response_type=code&
    scope=https://www.googleapis.com/auth/drive&
    access_type=online

    The response returned contains an authorization code that will be used to generate the access token in the next step.

  6. Generate the access token by performing an HTTP POST request using Google REST Console. To do this, copy and paste the request URL https://www.googleapis.com/oauth2/v3/token with the following query string parameters into the Request URI field in the Target area, select the Content-Type check box and set its value to application/x-www-form-urlencoded, then click the POST button.

    • code: the authorization code generated in the previous step.

    • client_id: the value of CLIENT ID from the Credentials view.

    • client_secret: the value of CLIENT SECRET from the Credentials view.

    • redirect_uri: the value of REDIRECT URIS from the Credentials view.

    • grant_type: the value is authorization_code.

    Note that the request URL and the query string parameters are concatenated with a question mark ?, and every two query string parameters are concatenated with an ampersand &. An example URL is shown below, with line breaks for readability. You need to join all these lines into one line before copying and pasting the URL into the Request URI field.

    https://www.googleapis.com/oauth2/v3/token?
    code=4/fwRIPH2a8XQRCs2JicTs4zWTprKjyJ7KbwkY46fE1O0.sj6y9PmBGe8ZeFc0ZRONyF4NK_eblwI&
    client_id=1061335238805-gmctuidvid0lsrdf66nvit0g7j5gnrck.apps.googleusercontent.com&
    client_secret=x6Jis-fzAzBfCfrLlokuPopn&
    redirect_uri=urn:ietf:wg:oauth:2.0:oob&
    grant_type=authorization_code

    The response returned contains the access token. Note that the access token expires in every 3600 seconds.