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.
3. Now select Google Drive API from project Dashboard and click on ‘Try in API Explorer.’
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’.
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
6. Copy your Client ID and Secret Key somewhere. You will need these in the next steps.
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.
8. On the ‘OAuth 2.0 Playground’ Step 2 tab, click ‘Exchange authorization code for tokens’ to generate the OAuth access token.
Configuring REST Client¶
9. Now open Centerprise client and configure Rest Client with the following settings:
10. Create layout in Centerprise using sample JSON text to retrieve data from Google drive.
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.