Google Workspace: Generate Token
Enable APIs
- Go to the Google Developer Console.
- Click Select a Project >> New Project. If you have an existing project, you can select it from ALL.
- Provide valid values, and click Create.
- Navigate to Dashboard, and click on ENABLE APIS AND SERVICES.
- Search for Google Drive API and Google Sheets API, and click Enable.
Get a Client ID and Client Secret
- Navigate to the tab OAuth consent screen and choose the valid option.
- Enter the Application name and Authorized domains, and click Save.
- Click Credentials tab >> Create Credentials, and OAuth client ID from the dropdown list.
- In the Application type list, select Web Application.
- Enter valid Name and Authorized Redirect URIs, and click Create.
- Copy Client ID and Client Secret, and click OK.
- Click OAuth 2.0 Client IDs, and get Client ID and Client Secret.
Generate Refresh Token
- Go to the Google OAuth Playground
- Click Settings icon.
- Click Use your own OAuth credentials, and enter OAuth Client ID and OAuth Client secret generated in Get Client ID and Client Secret
- Select Select & authorize APIs. Select the desired scope you want for your application and click on Authorize APIs.
Required Scope:
https://www.googleapis.com/auth/admin.directory.user
https://www.googleapis.com/auth/admin.directory.domain
https://www.googleapis.com/auth/admin.directory.group
- 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.