Enable Google APIs and Obtain OAuth Credentials
This guide provides step-by-step instructions for enabling the Google Calendar and Drive APIs and obtaining OAuth credentials and a refresh token using the OAuth 2.0 Playground.
Enabling the Google APIs
Sign in to the Google Cloud Console using your Google account. If you don’t have one, sign up for a free account.
Select or create a project where you want to enable the Google APIs.
In the left-hand menu, navigate to APIs & Services > Library.
In the search bar, type “Google Calendar API” and select it from the search results.
Click Enable to activate the API for your project.
Repeat steps 4 and 5 for the “Google Drive API”.
Obtaining OAuth 2.0 Credentials
In the Google Cloud Console, go to APIs & Services > Credentials.
Click on Create Credentials and choose OAuth client ID.
Select the application type as Web application.
Specify the name of your application.
In the Authorized redirect URIs field, enter the following URI:
https://developers.google.com/oauthplayground
Click Create.
Download the credentials file (JSON) containing your client_id and client_secret.
Go to APIs & Services > Oauth consent screen.
Select External for the user type.
Click Create.
Configure the OAuth consent screen by providing the the following information:
Application name
User support email
Developer email
Click Save And Continue and use the default settings for the remaining screens.
On the OAuth consent screen, click Publish App.
Using OAuth 2.0 Playground to Obtain a Refresh Token
Open the OAuth 2.0 Playground.
Click on the gear icon in the top-right corner to open the settings.
Check the option Use your own OAuth credentials and paste the client_id and client_secret from your downloaded credentials file.
In the Step 1 section, select and authorize the following APIs:
Drive API v3 > https://www.googleapis.com/auth/drive
Google Calendar API v3 > https://www.googleapis.com/auth/calendar
Click Authorize APIs. You will be redirected to a Google sign-in page to grant access.
After authorization, you will be redirected back to the playground. In the Step 2 section, click Exchange authorization code for tokens.
You will receive an access_token and a refresh_token. Copy and save the refresh_token for future use.