Skip to main content

Google Drive

Generate Google Drive client ID and secret

  1. Go to https://console.cloud.google.com and select an existing project or create a new one. In this example, we create a new project TDMS. Click on CREATE PROJECT
    Google API Console
  • Enter the Project Name, and click create. You will be redirected to the Dashboard screen. Google API Console
  1. Go to the Library page in the right panel, find Google Drive API and enable the Google Drive API that allows you to access resources from Google Drive. Google API ConsoleGoogle API Console
  2. Go to the Credentials menu link, in the right panel. Click CONFIGURE CONSENT SCREEN, select User Type as External and click CREATE. Set an Application name in the Application name field. In this example, it is my-project-app. click Save. Google API ConsoleGoogle API ConsoleGoogle API Console
  3. Click Credentials > +CREATE CREDENTIALS > OAuth client ID, and in the Create OAuth client ID page, create a new client ID with Name my-project-Application with Application type set to Web application, and Authorized redirect URIs set as https://developers.google.com/oauthplaygroundGoogle API ConsoleGoogle API Console
  4. Click Create. You will be shown your client ID and client secret that you can use to generate access_token for your account Google API Console

Generate access_token for Google Drive using a client ID and secret

To generate access token to access Google Drive, you need to first generate the access token by completing the following steps using Google Developers OAuth Playground.

  1. Go to https://developers.google.com/oauthplayground/
  2. Click OAuth 2.0 Configuration and select Use your own OAuth credentials checkbox, enter the OAuth client ID and client secret you have already created in the OAuth Client ID and OAuth Client secret fields respectively.  Google Developers OAuth Playground
  3. In OAuth 2.0 Playground Step 1, select the scope https://www.googleapis.com/auth/drive under Drive API v3 for the Google Drive API and click Authorize APIs, then click Allow to generate the authorization code. You will be redirected to your google account login page for authentication enter your login details and sign in to your account.  Google Developers OAuth Playground
  4. In OAuth 2.0 Playground Step 2, click Exchange authorization code for tokens to generate the OAuth access token.  Google Developers OAuth Playground The OAuth access token is displayed on the right panel as shown in the below figure. copy the whole JSON structure and save it in a file, we shall be calling it token file.  Google Developers OAuth Playground Congratulations, you are done!

Setting up your Google drive storage on CloudTDMS

Open the storages tab and insert the following values for your new Google Drive storage

  • Name: Name for the storage
  • Credential File: Contents of token file downloaded from Google Developers OAuth Playground
  • Token File: Contents of token file downloaded from Google Developers OAuth Playground
  • Path: Path of the folder where CloudTDMS will save the generated files or fetch files for profiling

NOTE

You will need to add client_id and client_secret parameters to your Token File which you used earlier to generate access token. The final Token File should be of the following format

{
"client_id": "157824523406-8d1acl3sdbjh2mt6mmkjm2pv7bj12c2m.apps.googleusercontent.com",
"client_secret": "7zDwyowQgXyLBwvOJhIDUOMj",
"access_token": "ya29.zS9NQKsZliTZe7y7pDDp_KGoEmpx2yyNLPya0AVvZVsqaQ4G09YdvUx-fV0EkPqgA-wBDrBxn0h1hMFeXW83jedPWkuwtY-HHa2nVnalQcbyUx90d0MTPq0qi3jgL-x0dsOoJEzPxNfitQTXWitmVpTUDznR9XKAUQS016337gvARESFQGbdwaI4pvm8Azhik6vMzLiiXaCgY",
"scope": "https://www.googleapis.com/auth/drive",
"token_type": "Bearer",
"expires_in": 3599,
"refresh_token": "1//GAQSNg04dIARAAFeHGnK2zhz6CgY-rpvtNgdOvXhsgz6GRTL9I8X2OR29eeQ4IuxJureWw8dEBTrduGMbN2EapZoM0fYY1l_yow"
}