Obtain OAuth 2.0 credentials from Google
You can obtain the OAuth 2.0 credentials for your app from the Google API Console (https://console.cloud.google.com/). This implies creating a new project for your app if you haven’t done so yet, configuring an OAuth consent screen, and then creating credentials of type Web Application. Once this process is complete, you can download your authorization details as JSON.
To obtain OAuth 2.0 credentials from the Google API Console:
-
In the Google API Console, click Select Project from the drop-down list at the top of the page, and then click New Project.
-
Enter a project name. If your Google account is part of an organization, select the organization to which this project belongs.
-
Click Create.
-
Select your newly created project from the list at the top of the page.
-
In the navigation menu, click APIs & Services > OAuth Consent Screen.
-
Click External.
-
Fill in the application details as required. At the minimum, you will need to provide an app name, a support email, and a developer email.
-
Click Save & Continue.
-
Click Add or remove scopes, and then select the scopes
.../auth/userinfo.email
and.../auth/userinfo.profile
. -
Click Update. Your application’s scope should now be visible under Your non-sensitive scopes.
-
Click Save & Continue.
-
Optionally, add some test users for your application, and then click Save & Continue.
-
From the navigation menu, select APIs & Services > Enabled APIs & services.
-
Click Enable APIs & Services.
-
Search for the Gmail API and click Enable.
-
From the navigation menu, select APIs & Services > Credentials.
-
Click Create Credentials, and select OAuth Client ID as credential type.
-
Select Web Application as application type, and then enter a name for your client app, for example:
-
Under “Authorized Redirect URIs”, click Add URI, and enter the URL to which users of your app should be redirected after they allow your app access to their Google account. As further described below, you will need to handle requests at this URL in order to complete the authorization process.
-
Click Create. Your OAuth 2.0 client has now been created, and you can download it as JSON from the Credentials page.