Creating a Custom OAuth App
OAuth custom applications are required for desktop applications, web applications, and headless machines.
Enable the Gmail API
Follow these steps to enable the Gmail API:- Navigate to the Google Cloud Console.
- Select Library from the left-hand navigation menu. This opens the Library page.
- In the search field, enter "Gmail API" and select Gmail API from the search results.
- On the Gmail API page, click ENABLE.
Create an OAuth App for User Account Authentication
Follow the procedure below to register an app and obtain the OAuthClientId and OAuthClientSecret.
Desktop Applications
Follow the steps below to obtain the OAuthClientId, OAuthClientSecret.
- Log into the Google API Console.
- Click Create Project or select an existing project.
- In the API Manager, select Credentials > Create Credentials > OAuth Client Id.
- Select the application type. If you are making a desktop application, select Other.
- Create a consent screen if there are none available in your selected organization. A caveat: If you are not using a Google Workspace account, you are restricted to creating an External-type Consent Screen, which requires specifying a support email and developer contact email. Additional info is optional.
- Click Create. The OAuthClientId and OAuthClientSecret are displayed.
- Select Library > Gmail API > Enable API. >
Create an OAuth App for Service Account Authentication
Follow the steps below to create an OAuth application and create a private key:
- Log into the Google API Console.
- Click Create Project or select an existing project.
- In the API Manager, select Credentials > Create Credentials > Service Account Key. In the Service Account menu, select New Service Account or select an existing service account. In the "Key Type" section, select the P12 key type.
- Click Create. The key pair is downloaded and the private key's password is displayed.
- Select Library > Gmail API > Enable API.