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
- Navigate to Google Cloud Console.
- From the top nav bar, select an existing project or create a new one.
- If creating a new project, name it whatever you want and then click Create.
Enable APIs for Gmail
- Once the project is selected or created, open the left sidebar and then navigate to APIs and services > Library
- Alternatively, you can search for Library from the top navbar.
- Search for Gmail API and click on the matching search result.
- Click Enable.
Configure your OAuth consent screen
- Open the left sidebar and navigate to APIs and services > Credentials.
- Alternatively, you can search for Credentials from the top navbar.
- Click Create Credentials and then select OAuth client ID.
- 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
- After configuring your consent screen, return to the Credentials home page, click Create credentials, and select OAuth client ID.
- Select Web application as the application type. Name your app whatever you want
- Under Authorised redirect URIs, enter
https://api.unified.to/oauth/code
- Click Create.
- 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.
- Navigate to the integration page for Gmail on Unified.to i.e https://app.unified.to/integrations/googlemail
- 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.
- In the Google Workspace Admin Console, navigate to Menu > Security > Access and data control > Google Cloud session control.
- 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.
- Under Reauthentication policy, select "Never require reauthentication"