Skip to main content
This guide sets up the Gmail connector with a Google service account. A Google Workspace is required. If you prefer to sign in with one Google account, follow the OAuth guide.

Authorization

1

Create a Google Cloud project

2

Enable the Gmail API and the Admin SDK API

  • In the left panel, open APIs & services and go to Enabled APIs and services.
  • Click + ENABLE APIS AND SERVICES.
  • Search for Gmail API and click ENABLE.
  • Search for Admin SDK API and click ENABLE.
Google Cloud Console enabling APIs for the project
3

Create a service account

  • Open the service accounts page in Google Cloud.
  • Click Create Service Account and complete step 1. Skip steps 2 and 3.
  • Open the Keys section and click Add Key. Download the JSON key.
For Google organizations created after April 2024, allow key creation first:
  • Open this policy page.
  • Select Manage, then Override parent’s policy, then Not enforced under Rules.
  • Select SET POLICY.
4

Grant domain-wide delegation

Give the service account read-only access to Gmail:
  • Copy the Unique ID of the service account.
  • Open the Domain-wide Delegation page in the Google Admin console.
  • Click Add new and enter the Unique ID as the client ID.
  • Paste this list into OAuth scopes: https://www.googleapis.com/auth/gmail.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.user.readonly

Indexing

1

Create the account

In the Onyx admin panel, go to Connectors and select Gmail. Under Authentication Account, click Create New and select Service Account.
  • Primary Admin Email: the email of a user with an admin role in the Google Workspace that has the Users > Read and Groups > Read privileges. This can be an existing admin or an account created for Onyx, such as onyx-robot@your-domain.com. Do not enter the service account email. Set the role in the Google Admin console under Account > Admin roles.
  • Service Account Key: upload or paste the JSON key you downloaded.
2

Choose document access

Under Document Access, select who can see the indexed threads. Sync with Gmail mirrors each user’s own mailbox. Specific Groups and Sync with Gmail are available on the Business and Enterprise plans and on Onyx Cloud. Then click Create Connector.
You can create more than one Gmail account on a single Onyx instance, each with its own service account. This lets you index multiple Google Workspaces from one Onyx deployment. Create a separate account and connector for each workspace.
A Google account is listed on both the Gmail and the Google Drive connector forms. To use one service account for both connectors, delegate the scopes of both: https://www.googleapis.com/auth/gmail.readonly,https://www.googleapis.com/auth/drive.readonly,https://www.googleapis.com/auth/drive.metadata.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.user.readonly. With only one connector’s scopes delegated, the account works for that connector only.