> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryassist.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Gmail Service Account

This guide walks you through connecting Gmail using a Service Account. For more details on Service Accounts can be found [**here**](https://cloud.google.com/iam/docs/service-account-overview)\*\*. \*\*Note that a Google Workspace account is required for this method

If you'd prefer to use an individual account with OAuth instead, refer to the OAuth setup section.

## Authorization

1. **Create a Google Cloud Project** Visit [https://console.cloud.google.com/projectcreate](https://console.cloud.google.com/projectcreate) and set up a new project.
2. **Enable Gmail API and Admin SDK**
   * On the left panel, open **APIs & services**
   * Go to **Enabled APIs and services**
   * On the top click **+ENABLE APIS AND SERVICES**
   * Search for **Gmail API** and click **ENABLE**
   * Alternatively visit this [**link**](https://console.cloud.google.com/flows/enableapi?apiid=gmail.googleapis.com), select your project and enable the **Gmail API**
   * Also enable **Admin SDK API** (search and enable)
     <Frame>
       <img src="https://mintcdn.com/ac-b0a71323/-HGlERJryMl2EiBX/images/Arc_xuFtuHxRWK-2.png?fit=max&auto=format&n=-HGlERJryMl2EiBX&q=85&s=932ce4d87ee40fbb483e8ea355143b08" alt="Arc Xu Ftu Hx RWK 2" width="1533" height="653" data-path="images/Arc_xuFtuHxRWK-2.png" />
     </Frame>
     3. **Create a Service Account**
   * Navigate to the [**Service Account management page**](https://console.cloud.google.com/iam-admin/serviceaccounts) in Google Cloud.
   * Click `Create Service Account.` Fill in the details in Step 1 — Steps 2 and 3 can be skipped.
   * Once created, go to the **Keys** section, click **Add Key**, and download the key file. You'll need to upload this to ASSIST AI later.
   * Note for Google Organizations created after April 2024:
     * To give the service account the proper permissions you will have to navigate to this [**link**](https://console.cloud.google.com/iam-admin/orgpolicies/iam-disableServiceAccountKeyCreation)
     * Then select `Manage`, select `Override parent's policy` and then select `Not enforced` under `Rules`.
     * Finally, select `SET POLICY`
3. **Grant Domain-Wide Delegation** This step gives the Service Account read-only access to Gmail.
   * Copy the `Unique ID` of the Service Account
   * Go to the [**Domain-wide Delegation page**](https://admin.google.com/ac/owl/domainwidedelegation) in the Google Admin Console.
   * Click `Add new`, fill in the client ID with the `Unique ID` of the Service account
   * Copy this comma separated list of scopes and paste it into field `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`
