Configuring Google Drive API through REST Client in Centerprise

Centerprise has an in-built REST service using which you can retrieve data residing on online sources such as Google drive. In this document, we will cover the REST API configuration required to call data from Google drive.

Getting the IDs and Names of Files Present in Google Drive

1. Create a new project on https://console.developers.google.com/apis.

2. On the Dashboard window, click ‘Enable APIs and Services’ and add Google Drive API.

../_images/128.png

3. Now select Google Drive API from project Dashboard and click on ‘Try in API Explorer.’

../_images/217.png

4. On the ‘API Explorer’ window, turn on ‘Authorize requests using OAuth 2.0’ option. At this step, you will be required to sign in to your Google drive account. Log in by providing your username and password and click ‘Allow’.

../_images/314.png

5. Now go back to the ‘Project’ dashboard and click ‘Credentials’ in the menu bar on the left. Click on ‘Create credentials’ drop-down button and select ‘OAuth Client ID’ from the drop-down list. Now, in the context menu, select ‘Web Application’ and in the ‘Authorized Redirect URLs’ field, type: https://developers.google.com/oauthplayground

../_images/49.png

../_images/59.png

6. Copy your Client ID and Secret Key somewhere. You will need these in the next steps.

../_images/69.png

7. Now go to https://developers.google.com/oauthplayground. Click ‘OAuth 2.0 Configuration’ and check the ‘Use your own OAuth credentials’ checkbox.

Enter the OAuth client ID and Client Secret Key (created in the previous step) in the OAuth Client ID and OAuth Client secret fields respectively.

Now type https://www.googleapis.com/auth/drive in Input Scope and click ‘Authorize.’ Click ‘Allow’ on the next screen.

../_images/79.png

8. On the ‘OAuth 2.0 Playground’ Step 2 tab, click ‘Exchange authorization code for tokens’ to generate the OAuth access token.

../_images/88.png

Configuring REST Client

9. Now open Centerprise client and configure Rest Client with the following settings:

../_images/98.png

10. Create layout in Centerprise using sample JSON text to retrieve data from Google drive.

../_images/108.png

Additional Note:

The token for REST client is generated outside Centerprise, that is, on the source platform you want to retrieve the data from. Once generated, this token can be used for multiple subsequent REST calls and you’ll be able to get the result as long as the token is not expired.

However, the token can also get expired for different reasons. It can be that the time duration is breached or because it hasn’t been in use for the required time frame.

Centerprise does not offer any such maintenance as to withhold this token expiry. This is outside the scope of the application and the expiry setting of the token is maintained and controlled by the online source platform itself.