> For the complete documentation index, see [llms.txt](https://herd-security.gitbook.io/herd-security-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/google-workspace.md). Agents can also search and read this documentation through its [MCP server](https://herd-security.gitbook.io/herd-security-docs/~gitbook/mcp).

# Google Workspace

How to connect Herd to Google Workspace so your organization can sync users and groups from your existing directory for training and simulation management.

## Google Workspace overview

Organizations that use Google Workspace as their identity provider can sync users and groups into Herd for training and simulation assignment and management. Herd uses Google’s Admin SDK API through the Google Cloud Console.

Herd reads your users and groups through a **service account**: a non-human Google identity that lives in a Google Cloud project you own. You download a key for it and paste that key into Herd. **Domain-wide delegation** then lets the service account read your directory on behalf of a Workspace admin, limited to the read-only scopes in Step 9. It cannot change users, groups or mail.

{% hint style="warning" %}
You need a Google Workspace super admin for Step 9. Only a super admin can grant domain-wide delegation. Steps 1 to 8 need someone who can create projects, service accounts and organization policies in Google Cloud. If that isn't you, send these steps to whoever it is.
{% endhint %}

Herd shows a short version of these steps in the app, on the Google Workspace page under **Settings → Integrations**.

### Step 1: Create a Google Cloud project

Create a separate Google Cloud project for this integration. That keeps it easy to manage and avoids conflicts with other Google Cloud integrations you add later.

1. Open Your Google Cloud Console, as an administrator.
2. On the top toolbar, click the box that says, *Select A Project*.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2Fr6CR3Fe8ALWi2Stj9qZy%2FScreenshot%202025-12-12%20at%2010.59.51.png?alt=media&amp;token=d82504d1-c52c-4e5e-913a-a224e602fd77" alt=""><figcaption></figcaption></figure>

3. On top left of the modal pop-up, select your organizations domain. Then select *New project.*
4. Name the project *Herd Integration*
5. Select your organization and location.
6. Select any location based on your preference.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FKaUYVasBHdfJglqbcq6O%2FScreenshot%202025-12-12%20at%2011.03.18.png?alt=media&amp;token=244a8d79-5e93-42ce-86dd-d6f3d940cfa4" alt=""><figcaption></figcaption></figure>

7. Click the blue **Create** button.

{% hint style="info" %}
Note: It may take several minutes for the project to create. It must be fully created before moving on to step 2. Check the progress within your Google Cloud notifications.
{% endhint %}

### Step 2: Select the project

Ensure you’ve selected the Herd project created in Step 1.

1. Select the box on the top toolbar with your organization name.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2F0eZKjwISrGMQmk5DrKP6%2FScreenshot%202025-12-12%20at%2011.06.10.png?alt=media&amp;token=8459d8b7-0be5-491f-a9fa-1c330714553a" alt=""><figcaption></figcaption></figure>

2. Select the project *Herd* *Integration*

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FJQfmCwDnE9YUprv206ZO%2FScreenshot%202025-12-12%20at%2011.33.08.png?alt=media&amp;token=7d4bf12b-eca7-4eaa-8878-76a754e58d90" alt=""><figcaption></figcaption></figure>

You’ll work in this project for the rest of the integration.

### Step 3: Enable the Admin SDK API

This integration uses Google’s existing Admin SDK API.

1. Select the hamburger stack symbol, to the left of the Google Cloud logo, in the top toolbar.
2. Within the navigation, go to **APIs & Services** and select **Enabled APIs & Services**.
3. Select the *+ Enable APIs and services.* At the top of the section. You’ll be taken to Google API Library

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FWkSJqfZY2gBAiSBNhPy0%2FScreenshot%202025-12-12%20at%2011.09.08.png?alt=media&amp;token=8b22ab64-5fc0-4bb5-8ff4-6672ea8a12d3" alt=""><figcaption></figcaption></figure>

4. In the search box, type in **Admin SDK API.**
5. Once found, select **Admin SDK API**, then click **Enable**.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FLC5EuHNJSLFxHEzWjmTi%2FScreenshot%202025-12-12%20at%2011.09.57.png?alt=media&amp;token=131b4662-1970-4aab-96d9-55da2c42527a" alt=""><figcaption></figcaption></figure>

### Step 4: Create a service account

Syncing all group membership needs a dedicated service account with domain-wide access.

1. Check the top toolbar and ensure you’re within the *Herd* project
2. Select the hamburger icon to open the left side navigation, go to **IAM & Admin** and select **Service Accounts**.
3. Select **+ Create service account** on the top toolbar

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FHRKGjXdCSSJjilnc485e%2FScreenshot%202025-12-12%20at%2011.12.05.png?alt=media&amp;token=a84c2e85-d54f-46a7-a1aa-764b721db6d2" alt=""><figcaption></figcaption></figure>

4. Enter a service account name, for example: **`herd-integration`** Then put a service account description **For Herd Integration.** The service account ID should automatically populate.
5. Click **Create and Continue**.
6. Skip role and user access (leave defaults) and click **Done**.

This creates the dedicated identity Herd will use to access your domain data via APIs.

### Step 5: Save service account details

You’ll need the new service account OAuth2 Client ID For Step 8

1. Copy and save the **OAuth 2 Client ID.** It is within the row that populated on the service account page and should be a 20-character string of numbers, for example: `234567890192872817`

### Step 6: Grant IAM permissions to the service account

1. Select the hamburger logo on the top left, next to the Google Cloud logo.
2. Hover over **IAM & Admin** and select **IAM.**
3. On the top toolbar, select the Herd Integration project in the box right of the Google Cloud logo.
4. Switch to the Organization level by selecting the Organization domain that the Herd Integration Project is within. This is likely your company's domain.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FLNO9VY9AHCrFbxdW3juP%2FScreenshot%202025-12-12%20at%2011.21.30.png?alt=media&amp;token=16d71e12-faae-4326-b425-4ece9241c589" alt=""><figcaption></figcaption></figure>

5. When the page updates, select the *+ Grant Access* button
6. With the **Add Principals** box, add the email of the account you’re currently logged into as an administrator in the google cloud console. This is likely your generic organizational email. Example: `<user>@yourcompany.com`
7. Under **Assign Roles** select the dropdown box and search for `Organization Policy Administrator` . Once found, select it. Then **Save.**

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FFYHXMxKMM37e6pu5oVUS%2FScreenshot%202025-12-12%20at%2011.26.11.png?alt=media&amp;token=3c29d09b-96c5-4889-b0bf-836bacad0be0" alt=""><figcaption></figcaption></figure>

### Step 7: Disable the legacy service key creation policy

By default, Google Cloud has an IAM policy that blocks creating JSON keys for service accounts, and the next step needs one. Disable this policy.

1. On the top toolbar, select the box with your Herd project and go back to the your organization.
2. Select the hamburger logo, hover over **IAM & Admin** and select **Organization Policies.**
3. Scroll down slightly to the filter box above the table that lists all active and inactive policies. Copy and paste: `iam.disableServiceAccountKeyCreation` and hit enter.
4. Select the policy name **Disable Service Account Key Creation,** it’ll match the ID that we pasted above.
5. On the right, select the pencil icon with **Manage Policy.**
6. Select the radio button next to **Inherit Parents Policy.**
7. Click **Set Policy.**
8. The status should show “Not Enforced” in the box below.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2Fxhft70RZGtTCGCh5xzSh%2FScreenshot%202025-12-12%20at%2011.55.55.png?alt=media&amp;token=ea10c7a6-e069-45c3-af52-6d225718c9ee" alt=""><figcaption></figcaption></figure>

### Step 8: Create and download a JSON key

1. On the top toolbar, select the box with your organization and go back to the Herd Integration Project.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FJQfmCwDnE9YUprv206ZO%2FScreenshot%202025-12-12%20at%2011.33.08.png?alt=media&amp;token=7d4bf12b-eca7-4eaa-8878-76a754e58d90" alt=""><figcaption></figcaption></figure>

2. Select the hamburger icon on the top toolbar, and hover over **IAM & Admin** then select **Service Accounts.**
3. Select the Service Account created in Step 4.
4. On the next page, there will be multiple tabs. Select the one that says **Keys.**

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2F4YaaX4S25rOJTZCp4F7K%2FScreenshot%202025-12-12%20at%2011.34.49.png?alt=media&amp;token=37e370c2-6f34-4802-a577-c028a7ae3e31" alt=""><figcaption></figcaption></figure>

5. Down the page, you’ll find a dropdown that says **Add Keys**. Select it and select **Create New Key.**
6. Select **JSON**, then click **Create**.
7. A JSON key file is downloaded to your computer.
8. Copy and save the key for use in the next step.

   > Treat this JSON file as a secret and store it securely. It grants API access when combined with domain-wide delegation.

* Note: If you get an error that the organizational policy is blocking the service account key creation, go back and ensure that Steps 6 and 7 were performed properly.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FA440xIEFgUHfhFS1WJjt%2FScreenshot%202025-12-12%20at%2011.36.22.png?alt=media&amp;token=a2e26030-6977-45ca-a8e6-c125abc967a5" alt=""><figcaption></figcaption></figure>

### Step 9: Configure domain-wide delegation in the Admin console

1. Open a new tab in your browser and go to the Google Admin console as a super admin:

   **`https://admin.google.com`**
2. On the left side toolbar, look for the **Security** dropdown. Note that it may be hiding under a “show more” button.
3. Select Security → Access and data control → API Controls.
4. On the bottom of the newly loaded page, look for the box named: **Domain-wide Delegation.** Select **Manage Domain Wide Delegation.**

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FLoI851LIuiTevwehxTfo%2FScreenshot%202025-12-12%20at%2012.01.10.png?alt=media&amp;token=80b56b0f-3b7a-44f6-97d6-e90473aa25ad" alt=""><figcaption></figcaption></figure>

5. You’ll be taken to a page titled API Clients. In the top toolbar, select **Add New.**
6. In **Client ID**, paste the **Client ID** of the **`herd-integration`** service account that was created in Step 5.
7. In **OAuth scopes (comma-delimited)**, paste the required scopes as one comma-separated line with no spaces:

   ```
   https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.customer.readonly
   ```

   The Google Workspace page in Herd has a **Copy required scopes** button that copies exactly this line.
8. Click **Authorize**.

| Scope                                                               | Required | What Herd reads with it                                                                                               |
| ------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
| `https://www.googleapis.com/auth/admin.directory.user.readonly`     | Yes      | Users (name, email, org unit, manager, status) for directory sync.                                                    |
| `https://www.googleapis.com/auth/admin.directory.group.readonly`    | Yes      | Groups and their members, for group sync and group targeting.                                                         |
| `https://www.googleapis.com/auth/admin.directory.customer.readonly` | Yes      | The Workspace customer record, to identify your tenant when you connect.                                              |
| `https://www.googleapis.com/auth/admin.directory.user.security`     | Optional | App inventory: which third-party apps your users have granted OAuth access to. Read only; Herd never revokes a grant. |

All three required scopes must be on the delegation entry. Google rejects Herd's whole request if any one is missing, and saving the configuration in Herd tests them. To also get the app inventory, add the optional scope to the same entry, comma-separated. Directory sync works without it.

To also count a compromised phone toward a person's risk score, see [Google Workspace Device Posture](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/google-workspace/google-workspace-device-posture.md), which adds two more optional device scopes to the same entry.

### Step 10: Connect Herd to Google Workspace

1. Open a new tab and login to your Herd Security admin console.
2. On the left side toolbar, select **Settings**, then choose **Integrations** in the Settings sidebar. The **Google Workspace** card is in the **Identity** section.
3. Scroll down to the Google Workspace Integration section and select the dropdown arrow next to **Google Workspace Configuration Settings.**
4. Provide the following values:
   1. Google Workspace Domain: **`yourcompany.com`**
   2. Admin Email: the email of a Workspace admin in the same domain who can view users and groups. A super admin always works. The service account makes its read-only directory requests on this person's behalf, limited to the scopes in Step 9. It cannot read their mail or change anything.
   3. Service Account JSON Key: open the key file downloaded in Step 8 and paste the whole thing, braces included.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FNhc763DQ3MgULFwCCINb%2FScreenshot%202025-12-12%20at%2012.08.32.png?alt=media&amp;token=9aea1cc3-a0a1-4ef2-9b45-531791d6b97b" alt=""><figcaption></figcaption></figure>

5. Select Save Google Workspace Configuration. Saving tests the connection straight away.

{% hint style="info" %}
If Google rejects the connection as unauthorized, the delegation from Step 9 is usually still propagating. Wait a few minutes and save again. If it keeps failing, check that all three required scopes are on the delegation entry and that the Client ID matches the service account.
{% endhint %}

### Step 11: Confirm user sync

1. On the same page, select **Sync Users**.
2. If successful, a status box with the last time grouped sync will appear.

<figure><img src="https://2286452423-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrNdsHrfHsFuaMzCbOD5q%2Fuploads%2FHnQ1rKB5yLxrKiRKGSaq%2FScreenshot%202025-12-12%20at%2012.08.59.png?alt=media&amp;token=d89ed2b5-6e7b-44d2-a4a1-8cc366f5877c" alt=""><figcaption></figcaption></figure>

You can now assign trainings to groups of users from your Google Workspace.

## Real-time directory changes

Once Google Workspace is connected, Herd subscribes to Google's change notifications for your users. A new hire, a deactivation or a profile change then reaches Herd within minutes instead of at the next 2-hourly sync. There is nothing to set up in Google. Each notification only tells Herd to re-read your directory through the normal sync, spaced out by directory size (from about 2 minutes for a small directory up to 30 for a slow one). While notifications keep arriving, the scheduled full listing runs once a day, overnight.

The **Real-time directory changes** block on the Google Workspace tile shows the status, for example "Connected. Last directory change applied …", "Partly connected (… of … change types)", or "Not connected. Directory changes reach Herd at the next scheduled sync (every 2 hours)." If Google refused a subscription, the block shows **Last answer from Google** with its reason. Click **Reconnect** to subscribe again.

## Sync scope: syncing only selected units and groups

By default Herd syncs your whole directory. To bring in only part of it, scope the sync to chosen **organizational units** (each including the units beneath it) and **groups** (including nested groups). It needs no extra scope in Google and is available on every plan.

Once connected, the tile shows the current scope (**Sync scope: entire directory (all users).** by default) with an **Edit sync scope** button.

1. Click **Edit sync scope** to open the **Google Workspace sync scope** dialog. Use **Search units and groups** to filter, and tick the units and groups to keep in sync. Leaving everything unticked syncs the whole directory.
2. Click **Review changes**. Herd shows what applying the scope would do before anything is written: how many users are in scope and how many would be excluded by sync scope.
3. Click **Apply scope** to save and start a sync, or **Back** to change the selection.

Users who leave the scope are excluded by sync scope: hidden, not deleted. Moving them back into a selected unit or group restores them. To return to a whole-directory sync, open the dialog, click **Clear selection** and then **Clear scope**; the sync that follows restores everyone the scope excluded. See [Okta's sync scope](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/okta/okta-group-and-app-sync.md#sync-scope-syncing-only-selected-okta-groups) for what an excluded user keeps.

Disabling the integration clears its sync scope and releases the people it excluded.

## Single sign-on with Google Workspace

Directory sync doesn't change how anyone signs in. To have your organization sign in to Herd with its Google Workspace accounts, see [Connect Google Workspace SSO](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/google-workspace/connect-google-workspace-sso.md).
