First, set up a project in Google Developers Console https://console.developers.google.com/ by clicking the drop-down at the top that will open a new window that shows New Project


Then select that project, click on the Google Cloud Platform and make sure your project shows in the drop down next to it.

Navigate to APIs & Services -> Credentials -> Manage service accounts to add a new service account to this project


Create a new, fill out service account information by clicking the Create Service Account at the top

Add the name you want for the service account display

It will take you back to service accounts, now click the Actions (ellipses) icon and select Manage keys

Click the ‘Add key’ button, then ‘Create new key’, select .p12 and create


Do not change the private key password, which should default to ‘notasecret’.
Please note where the file downloads to, you will need the name of this file and then you need to move it into the working directory of the Media Gateway running this Universal Connector.
\
Once that is done, you will need to return to the ‘Service accounts’ page, click the service account where it is linked to pull up the Service account details.
In the details, please copy and save for now the Email and the Unique ID; we will need these later

Expand the Advanced settings and then Under the ‘Domain-wide delegation’ and click the button to go to the Admin Console.
In the Admin console, search for Security in the top bar, then scroll down and select API Controls.

Scroll down and select "Manage Domain Wide Delegation"

Here you will add a new client using the Client ID from the service you created.
Click ‘Add new’, and in the ‘Client ID’, put in the ‘Unique ID’ that we noted from the service account before. In ‘OAuth Scopes’, input ‘https://mail.google.com/,email,profile’. Then ‘Authorize’.
Now we just need to set up the email in the Universal Connector. In MediaGateway, navigate to Universal Connector -> Connector -> Add, and select Email.
- Format: GSuite IMAP4/SMTP,
- Email Service Account: the Email that we noted from the service account before (publisher@publisher-309313.iam.gserviceaccount.com in the case of our examples),
- Email User Name: an email user of user in the GSuite that has an active inbox, and
- Email password: the name of the .p12 file
(The file name is including .p12. Remember this file MUST be in the working directory of the MediaGateway.)
Save, and the Universal Connector can now use gmail OAuth to connect to email.