Appendix 15: Google Refresh Token Generation
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 Spreadsheet steps prerequisites.
- Enable APIs for Google Drive and Google Spreadsheet
- Generate Client ID and Client Secret
- Generate Refresh Token in exchange for the Client ID and Client Secret
Google Spreadsheet documentation
In this section we will Enable APIs for Google Drive and Google Spreadsheet.
- Go to the Google Developer Console (https://console.developers.google.com/)
- Click Select a Project or create a New Project. If you have an existing project, you can select it from ALL.
- Provide valid values for the project and click on the Create button.
- Navigate to Dashboard on Google Developer console and Click on ENABLE APIS AND SERVICES.
- Search for Google Drive API and Google Sheets API. Click on Enable.
- The following screenshot shows Google Sheets API. Click on Enable.
Get a Client ID and Client Secret
- Navigate to the tab OAuth consent screen and choose the valid option.
- Enter the Application name, Authorized domains, and click on the Save button.
- Click on Credentials menu >> Create Credentials and from the dropdown list select OAuth client ID.
- From the Application type, select the Web Application.
- Enter valid Name and Authorized Redirect URIs. Click on the Create button.
- Copy Client ID and Client Secret. Click on the OK button.
- Get Client ID and Client Secret by clicking on the OAuth 2.0 Client IDs.
Generate Refresh Token
In this section we will generate Refresh Tokens using Client ID and Client Secret on Google OAuth 2.0 Playground.
- Go to the Google OAuth Playground (https://developers.google.com/oauthplayground/)
- Click on the Settings icon.
- Click on Use your own OAuth credentials and enter OAuth Client ID and OAuth Client secret generated from the previous step.
- Copy the following URL ‘https://developers.google.com/oauthplayground’
- Open the Credentials tab on Google Developer Console, select created Client ID by clicking on the Name.
- Paste the above copied URL in Authorised redirect URIs and click on Save button.
- Navigate back to Google OAuth Playground and click on Select & authorize APIs.
- Select the Select & authorize APIs. Select the desired scope you want for your application and click on Authorize APIs.
- Select the following scope under tab Drive API v3 - ‘https://www.googleapis.com/auth/drive’
- Click on Exchange authorization code for tokens.
- You’ll get the Authorization code, Click on the Exchange authorization code for tokens button.
- Copy Refresh Token.
This completes the process of Enabling APIs, getting Client ID and Client Secret and Generation of Refresh Token required for connecting to google Spreadsheet.