Skip to main content

Google Drive: Generate Token

It is assumed that you have a Google developer console account created on https://console.developers.google.com. In this Appendix we complete the Google Drive steps prerequisites.

  • Enable APIs for Google Drive.
  • Generate Client ID and Client Secret
  • Generate Refresh Token in exchange for the Client ID and Client Secret

Enable APIs

In this section we will Enable APIs for Google Drive.

  1. Go to the Google Developer Console.
  2. Click Select a Project >> New Project. If you have an existing project, you can select it from ALL.
10.1step2
  1. Provide valid values and Click on the CREATE button.
10.1step2
  1. Navigate to Dashboard and Click on ENABLE APIS AND SERVICES.
10.1step4
  1. Search for Google Drive API for Google Drive Plugin >Click on ENABLE.
10.1step5

Procedure to get a Client ID and Client Secret

  1. Navigate to the tab OAuth consent screen and choose the valid option.
10.1step5
  1. Enter the App name, User support email, Authorized domains, Developer contact information > click SAVE AND CONTINUE button.
10.1step5
  1. Click on ADD OR REMOVE SCOPES button.
10.1step5
  1. Select Google Drive API and scope selected in following image > click UPDATE button > click SAVE AND CONTINUE button.
10.1step5
tip

Select appropriate permissions required to perform the specific actions desired by you.

  1. Click on ADD USERS button.
10.1step5
  1. Provide valid email ID > click ADD button > click SAVE AND CONTINUE button.
10.1step5
  1. Click on Credentials tab > click CREATE CREDENTIALS and from the dropdown-list select OAuth client ID.
10.1step5
  1. From the Application type, select the Web Application.
10.1step5
  1. Enter valid Name and Authorized Redirect URIs > Click CREATE button. Authorized Redirect URIs: https://developers.google.com/oauthplayground
10.2step9
  1. Copy Client ID and Client Secret > click OK button.
10.2step10
  1. Get Client ID and Client Secret by clicking on the OAuth 2.0 Client IDs.
10.2step11

Procedure to generate Refresh Token

  1. Go to the Google OAuth Playground.
  2. Click on the Settings icon.
  3. Click on Use your own OAuth credentials and enter OAuth Client ID and OAuth Client secret generated from the previous step.
10.3step3
  1. Select the Select & authorize APIs. Select the desired scope you want for your application (like: https://www.googleapis.com/auth/drive ) > click Authorize APIs.
10.3step3

**Note: **Select appropriate permissions required to perform the specific actions desired by you.

  1. Choose an Account
10.3step3
  1. Sometimes following screen appears > click Allow
10.3step3
  1. Following consent screen appears, then click on Continue.
10.3step3
  1. Click on Exchange authorization code for tokens.
10.3step3
  1. You’ll get the Authorization code, Click on the Exchange authorization code for tokens button.

  2. Copy the Refresh Token.

Refresh Token Expiration

For more details on token expiration, refer to the: OAuth2.0 Documentation.