How to get your OAuth 2 credentials for Gmail


June 25, 2024

To access Google services such as Gmail (a.k.a Google Mail) with the Unified API, you will need to generate and retrieve your OAuth 2 credentials in the Google Cloud Console.

Create or select a project on Google Cloud Console

  1. Navigate to Google Cloud Console.
  2. From the top nav bar, select an existing project or create a new one.
    1. If creating a new project, name it whatever you want and then click Create.

Enable APIs for Gmail

  1. Once the project is selected or created, open the left sidebar and then navigate to APIs and services > Library
    1. Alternatively, you can search for Library from the top navbar.

  2. Search for Gmail API and click on the matching search result.
  3. Click Enable.
  1. Open the left sidebar and navigate to APIs and services > Credentials.
    1. Alternatively, you can search for Credentials from the top navbar.
  2. Click Create Credentials and then select OAuth client ID.
  3. You will be asked to configure the OAuth Consent Screen. Click Configure Consent Screen and go through the consent screen process.

Get your Oauth credentials

  1. After configuring your consent screen, return to the Credentials home page, click Create credentials, and select OAuth client ID.
  2. Select Web application as the application type. Name your app whatever you want
  3. Under Authorised redirect URIs, enter https://api.unified.to/oauth/code
  4. Click Create.
  5. After creating your credentials, a dialog window will appear displaying your new Client ID and Client secret. Make a note of these as you will need them for the next step.
  6. Navigate to the integration page for Gmail on Unified.to i.e https://app.unified.to/integrations/googlemail
  7. Enter your client ID, client secret, and developer API key to activate the Gmail integration.

Set your Oauth 2 reauthentication policy

Make sure your OAuth2 Reauthentication policy is set correctly for the integration to function as expected.

  1. In the Google Workspace Admin Console, navigate to Menu > Security > Access and data control > Google Cloud session control.
  2. On the left, select the organizational unit where you want to set session length. For all users, select the top-level organizational unit. Initially, an organizational unit inherits the settings of its parent.
  3. Under Reauthentication policy, select "Never require reauthentication"
Are we missing anything? Let us know
Was this page helpful?