Skip to main content

Configuring Gmail for OAuth

Connect ServiceOps to Gmail using OAuth to send and receive emails securely, without storing passwords in the system.

What is OAuth?

OAuth is an Open Standard Authorization protocol that allows one application to authenticate with another on your behalf without sharing a password. It uses client credentials to obtain short-lived access tokens, keeping email communication secure.

This functionality is applicable from version 8.1 and above.

How OAuth Works with ServiceOps

ServiceOps uses the Google OAuth client you register as a secure intermediary for email authentication. During setup, you provide the Client ID, Client Secret, and Scope to ServiceOps. When ServiceOps needs to send or receive email, it contacts Google using these credentials to obtain a short-lived access token. Google validates the credentials against your OAuth client and returns the token. ServiceOps uses that token to access the mailbox and refreshes it automatically before it expires, so no passwords are stored in ServiceOps at any point.

Prerequisites

  • A Google account with access to Google Cloud Console.
  • IMAP or POP3 must be enabled on the Gmail account before configuring it for incoming email.
  • The Redirect URL must use HTTPS. A valid SSL certificate is required on the ServiceOps server.
  • ServiceOps version 8.1 or above.

Configuring Gmail as OAuth Provider

Step 1: Sign in to Google Cloud Console

Sign in to Google Cloud Console and click Create Project.

Google Cloud Console showing the Create Project button

Step 2: Create a New Project

Enter the Project Name and click Create.

New project name entry form in Google Cloud Console

The project dashboard appears.

Google Cloud Console project dashboard after project creation

Go to the OAuth consent screen tab and click Get Started.

OAuth consent screen tab in Google Cloud Console

In the Overview tab, configure the project:

OAuth consent screen overview configuration form

  • Enter the App name and User Support Email, then click Next.
  • Select the Audience:
    • Select Internal if you are creating an app for your organization.
    • Select External if you are testing using a standalone Gmail account.

Audience selection for OAuth consent screen

  • Enter the Contact Information and click Next.

Contact information entry for OAuth consent screen

  • In the Finish step, enable the I agree checkbox, click Continue, and then click Create.

Finish step of OAuth consent screen setup with I agree checkbox

The app is created.

Step 4: Configure Branding (Optional)

Go to the Branding tab and configure details such as App Logo, App Domain, and Authorized Domain.

Branding tab in Google Cloud Console OAuth configuration

Step 5: Add Test Users

In the Audience tab, add test users and click Save. Ensure you add yourself as a tester.

Audience tab showing test users section in Google Cloud Console

Step 6: Create an OAuth Client

Go to the Clients tab and click + Create Client.

Clients tab in Google Cloud Console with Create Client button

Enter the following details:

OAuth client creation form showing application type and redirect URI fields

  • Application Type: Select Web Application.

  • Name: Enter the name of the web client.

  • Authorised Redirect URIs: Enter the redirect URI.

    Syntax: https://{server URL}/oauth/callback

    Example: https://dummy.com/oauth/callback

Click Create. The Client ID and Client Secret are displayed. Copy both values or download the JSON file.

OAuth client created showing Client ID and Client Secret values

The downloaded JSON contains all the required credentials.

Downloaded JSON file with OAuth client credentials

Step 7: Add Gmail API Scope

Go to the Data Access tab and click Add or Remove Scopes. Select the Gmail API from the list and click Update.

Data Access tab showing Add or Remove Scopes button

If the Gmail API is not available in the list, click Google API Library, search for Gmail API, and enable it.

Google API Library search showing Gmail API

Gmail API page in Google API Library with Enable button

Click Save once the scope is added.

Data Access tab with Gmail API scope saved

Configuring Gmail in ServiceOps (Incoming)

Navigate to Admin > Support Channel > Emails > Incoming Email Servers and click Add Incoming Email Server.

Add Incoming Email Server form configured for Gmail OAuth authentication

Enter the following details:

ParameterDescription
NameEnter the name of the email server.
EmailEnter the Gmail address used for authentication.
ProtocolSelect IMAP or POP3. The selected protocol must be enabled on the Gmail account.
Technician GroupSelect the technician group assigned to requests created via this email.
CategorySelect the category assigned to requests created via this email.
Proxy ServerSelect the required proxy server. Leave blank if ServiceOps has direct internet access.
Email ProviderSelect Other.
ServerEnter imap.gmail.com for IMAP or pop.gmail.com for POP3.
PortEnter the port number. Common values: IMAP: 993, POP3: 995.
Security TypeSelect SSL or TLS.
Email Auth TypeSelect OAuth.
Client IDPaste the Client ID from Step 6.
Client SecretPaste the Client Secret from Step 6.
Authorization URLEnter https://accounts.google.com/o/oauth2/v2/auth.
Token URLEnter https://oauth2.googleapis.com/token.
ScopeEnter https://mail.google.com/.
Redirect URLEditable field. Set from the Application Settings Base URL.
EnabledToggle to enable or disable the server.
PrimaryEnable to use this server as the primary incoming server.
Outgoing Email ServerEnable to associate an outgoing email server.
Filter TypeSelect Allow to accept only emails from the specified addresses, domains, or keywords (all others are blocked), or Ignore to silently discard emails matching the specified values (all others are allowed). If no filter is configured, ServiceOps accepts emails from all senders by default.
EmailsEnter specific email addresses to filter. With Allow, only these addresses can create tickets. With Ignore, emails from these addresses are silently discarded. Example: hr@company.com. Multiple entries work as OR conditions.
DomainsEnter domain names to filter, without the @ symbol. Example: yahoo.com. With Allow, only emails from these domains create tickets. With Ignore, all emails from these domains are silently discarded. Multiple entries work as OR conditions.
KeywordsEnter words or phrases to match against the email subject and body. With Allow, only emails containing these keywords create tickets. With Ignore, matching emails are silently discarded. Multiple entries work as OR conditions.
POP3 Authentication

POP3 supports only Basic Authentication. Select IMAP when using OAuth.

Click Save. You will be redirected to the Google sign-in page.

Google sign-in page during OAuth authorization flow

Select the account and click Continue.

Google permissions acceptance screen during OAuth authorization

Click Continue again. You will be redirected to the Incoming Email Servers page with the configured server listed.

Configuring Gmail in ServiceOps (Outgoing)

Navigate to Admin > Support Channel > Emails > Outgoing Email Servers and click Add Outgoing Email Servers.

Enter the following details:

ParameterDescription
NameEnter the name of the email server.
EmailEnter the Gmail address used as the From address for all notifications.
ProtocolSelect SMTP.
Sender NameEnter the display name shown to recipients alongside the From address.
Email ProviderSelect Other.
ServerEnter smtp.gmail.com.
PortEnter the port number. Common values: SMTP (TLS): 587, SMTP (SSL): 465.
Security TypeSelect SSL or TLS.
Authentication NeededEnable to authenticate with the server.
Email Auth TypeSelect OAuth.
Client IDPaste the Client ID from Step 6.
Client SecretPaste the Client Secret from Step 6.
Authorization URLEnter https://accounts.google.com/o/oauth2/v2/auth.
Token URLEnter https://oauth2.googleapis.com/token.
ScopeEnter https://mail.google.com/.
Redirect URLEditable field. Set from the Application Settings Base URL.
Reply-To EmailEnter the email address to which recipient replies will be directed. Set this to a monitored mailbox so replies are captured and converted into tickets.
Proxy ServerSelect the required proxy server. Leave blank if ServiceOps has direct internet access.
EnabledToggle to enable or disable the server.
PrimaryEnable to use this server as the fallback when other configured outgoing servers are unavailable.
Filter TypeSelect Allow to send emails only to the specified addresses or domains (all others are blocked), or Ignore to silently block emails to the specified values (all others are allowed). If no filter is configured, ServiceOps sends emails to all recipients by default.
EmailsEnter specific email addresses to filter. With Allow, only these addresses receive emails. With Ignore, emails to these addresses are silently blocked. Example: hr@company.com. Multiple entries work as OR conditions.
DomainsEnter domain names to filter, without the @ symbol. Example: company.com. With Allow, only addresses in these domains receive emails. With Ignore, all addresses in these domains are silently blocked. Multiple entries work as OR conditions.

Click Save. You will be redirected to the Google sign-in page. Select the account and grant the required permissions. You will be redirected to the Outgoing Email Servers page with the configured server listed. Verify connectivity using the Test Connection button.

Troubleshooting

Access Blocked: Authorization Error

This error occurs when an incorrect scope is configured. To resolve:

  1. Go to the Data Access tab in Google Cloud Console.
  2. Verify the scope is set to https://mail.google.com/.
  3. Click Save and retry the OAuth flow in ServiceOps.
Error 400: invalid_scope

This error means the scope entered in ServiceOps does not match a valid Gmail API scope. To resolve:

  1. In ServiceOps, open the email server configuration and check the Scope field.
  2. Ensure the value is exactly https://mail.google.com/ with no extra spaces or characters.
  3. Verify the Gmail API is enabled in the Google API Library.
Access blocked: app has not completed Google verification

This error occurs when the OAuth app is in testing mode and the signed-in user has not been added as a tester. To resolve:

  1. Go to the Audience tab in Google Cloud Console.
  2. Under Test users, add the email address you are using to sign in.
  3. Click Save and retry the OAuth flow.