> ## Documentation Index
> Fetch the complete documentation index at: https://university.triggr-app.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Workspace

> Connect each client's Google Workspace to Triggr with an OAuth client or a service account with domain-wide delegation.

Triggr manages each client's Google Workspace users, groups and domains, and can call other Google APIs from a Generic Integration Action step within the granted scopes.

Each client connects one of two ways, and you need a super admin in the client's Google Workspace for either:

* An OAuth client: Triggr acts as the admin who clicks Authorize.
* A service account with domain-wide delegation: the only way to change Gmail delegates and forwarding on other users' mailboxes.

## Set up an OAuth client

<Steps>
  <Step title="Create a project in the client's organisation">
    Signed in to the [Google Cloud console](https://console.cloud.google.com) as a client user, go to **IAM & Admin → Manage Resources > Create Project** and choose the client's organisation as the location.
  </Step>

  <Step title="Enable the APIs">
    In **APIs & Services → Library**, enable Admin SDK API, plus Gmail API and Google Calendar API if workflows use them.
  </Step>

  <Step title="Configure Google Auth platform">
    In **Google Auth platform → Branding**, click Get started, enter an App name and User support email, choose Internal under Audience, add a contact email and click Create. Leave Data Access empty: Triggr asks for its scopes when you authorise.
  </Step>

  <Step title="Create the OAuth client">
    In **Google Auth platform → Clients**, click Create client, choose Web application and add this under Authorized redirect URIs, then click Create and copy the Client ID and Client secret:

    ```text theme={null}
    https://app.triggr-app.com/oauth/callback
    ```

    Google shows the secret only once; if you lose it, open the client and click Add secret.
  </Step>
</Steps>

Triggr asks for these scopes when you authorise:

| Scope | Gives access to |
| - | - |
| `https://www.googleapis.com/auth/admin.directory.user` | Users |
| `https://www.googleapis.com/auth/admin.directory.user.security` | User security, such as signing users out |
| `https://www.googleapis.com/auth/admin.directory.group` | Groups and members |
| `https://www.googleapis.com/auth/admin.directory.domain.readonly` | Domains (read only) |
| `https://www.googleapis.com/auth/admin.directory.orgunit.readonly` | Organisational units (read only) |
| `https://www.googleapis.com/auth/calendar.readonly` | Calendars (read only) |
| `https://www.googleapis.com/auth/gmail.settings.basic` | Gmail settings |
| `https://www.googleapis.com/auth/gmail.settings.sharing` | Gmail delegates and forwarding |

If the client restricts API access, tick Trust internal apps in the [Admin console](https://admin.google.com) under Security → Access and data control → API controls, or set the app to Trusted in Manage App Access.

## Set up domain-wide delegation

<Steps>
  <Step title="Enable the APIs">
    In the [Google Cloud console](https://console.cloud.google.com), enable Admin SDK API and the APIs your workflows call, such as Gmail API, Google Calendar API, Google Drive API or Enterprise License Manager API.
  </Step>

  <Step title="Create a service account and key">
    In **IAM & Admin → Service Accounts**, click Create service account (it needs no project roles). Open it, go to **Keys > Add key → Create new key**, choose JSON and click Create, then copy the Client ID from Advanced settings.

    <Warning>The key can act as any user in the client's domain. Delete the downloaded file once it's in Triggr.</Warning>

    If key creation is blocked, an Organization Policy Administrator must relax the [`iam.managed.disableServiceAccountKeyCreation`](https://docs.cloud.google.com/resource-manager/docs/secure-by-default-organizations) policy for the project.
  </Step>

  <Step title="Authorise it in the client's Admin console">
    As a super admin in the [Admin console](https://admin.google.com), go to **Security → Access and data control → API controls → Manage Domain Wide Delegation**, click Add new, enter the Client ID and add these scopes under OAuth scopes:

    ```text theme={null}
    https://www.googleapis.com/auth/admin.directory.user
    https://www.googleapis.com/auth/admin.directory.group
    https://www.googleapis.com/auth/admin.directory.orgunit
    https://www.googleapis.com/auth/admin.directory.user.security
    https://www.googleapis.com/auth/admin.directory.device.mobile
    https://www.googleapis.com/auth/admin.directory.domain.readonly
    https://www.googleapis.com/auth/admin.datatransfer
    https://www.googleapis.com/auth/apps.licensing
    https://www.googleapis.com/auth/gmail.settings.basic
    https://www.googleapis.com/auth/gmail.settings.sharing
    https://www.googleapis.com/auth/calendar
    https://www.googleapis.com/auth/drive
    ```

    Click Authorize, then View details on the entry to check every scope is listed. Changes can take up to 24 hours. See Google's [Control API access with domain-wide delegation](https://knowledge.workspace.google.com/admin/apps/control-api-access-with-domain-wide-delegation).
  </Step>
</Steps>

## Connect it in Triggr

<Steps>
  <Step title="Open the client's configuration">
    Go to **Integrations > Google Workspace** and click **Configure** on the client's row in the Per-Client Configuration card.

    <Frame>
      <img src="https://mintcdn.com/triggr/nyuVXZ1rouDTTEvu/images/integrations-common/per-client-configuration.png?fit=max&auto=format&n=nyuVXZ1rouDTTEvu&q=85&s=11464b4946bea0b580c73330d9114a41" alt="The Per-Client Configuration card listing Acme Corp and Globex, each Not Configured with Admin Consent Not Required and a Configure button." width="2272" height="646" data-path="images/integrations-common/per-client-configuration.png" />
    </Frame>
  </Step>

  <Step title="Enter the client's details">
    * OAuth client: enter the ClientID, ClientSecret and the admin's Email, and leave ServiceAccountKey and DWDScopes empty.
    * Domain-wide delegation: paste the whole JSON key into ServiceAccountKey and a super admin into Email. ClientID and ClientSecret are required but unused: keep existing values, or enter the service account's client ID and `-`. Leave DWDScopes empty unless you authorised a shorter list.

    Click **Save Configuration**.

    <Frame>
      <img src="https://mintcdn.com/triggr/nyuVXZ1rouDTTEvu/images/google-workspace/configure.png?fit=max&auto=format&n=nyuVXZ1rouDTTEvu&q=85&s=35619e4726a22fd236dea63fb6debe82" alt="The Google Workspace configuration window with ClientID, ClientSecret, DWDScopes, Email and ServiceAccountKey fields, an Allow insecure TLS switch under Advanced, and a Save Configuration button." width="1344" height="1938" data-path="images/google-workspace/configure.png" />
    </Frame>
  </Step>

  <Step title="Authorize (OAuth client only)">
    Click **Authorize** on the client's row and sign in as the admin you entered. With a service account key, Triggr skips OAuth sign-in and acts as the mailbox owner for Gmail requests to a user's mailbox, and as Email for everything else.
  </Step>
</Steps>

Per-client integrations never fall back to the Base Configuration, so every client whose workflows use Google Workspace needs its own row. Leave the Base Configuration empty unless you connect your own Google Workspace for workflows that don't run for a client.

## Troubleshooting

<AccordionGroup>
  <Accordion title="redirect_uri_mismatch or org_internal when authorising">
    Check the OAuth client's redirect URI is exactly `https://app.triggr-app.com/oauth/callback`, and that you sign in with an account in the organisation that owns the project.
  </Accordion>

  <Accordion title="An API has not been used in project or is disabled">
    Enable it under APIs & Services → Library in that project, then wait a few minutes.
  </Accordion>

  <Accordion title="Delegation denied from Gmail">
    Changing another user's Gmail settings needs [domain-wide delegation](#set-up-domain-wide-delegation).
  </Accordion>

  <Accordion title="unauthorized_client or invalid_grant with a service account">
    Check the delegation uses the service account's client ID and authorises every scope Triggr requests (the default list, or DWDScopes if set), and that Email is an existing user in the client's domain. Delegation changes can take up to 24 hours.
  </Accordion>

  <Accordion title="ServiceAccountKey is not valid JSON, or is missing client_email or private_key">
    Paste the entire key file into ServiceAccountKey, from the opening `{` to the closing `}`.
  </Accordion>

  <Accordion title="Changing the authorising admin">
    Click Edit on the client's row, update Email, save, then click Authorize and sign in as the new admin.
  </Accordion>

  <Accordion title="Access token expired and no refresh token available">
    The client's configuration was saved but never authorised. Click Authorize on its row.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.