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

# Google Workspace Admin

> Connect Google Workspace without a service account key so agents, workflows, and apps can onboard and offboard employees.

The Google Workspace Admin connector lets Major run employee onboarding and offboarding in your Google Workspace domain:

* Create, suspend, and delete users.
* Add and remove users from groups.
* Assign licenses.
* Sign users out and revoke their app tokens.
* Transfer Drive and Calendar ownership to a manager.
* Set a departing user's Gmail auto-reply, forwarding, and delegates.

The connector is keyless. You create a Google Cloud service account with no key, and you let Major act as it through workload identity federation. Major never holds a long-lived Google credential. You then authorize the service account for domain-wide delegation in the Admin console.

You need a Google Workspace super admin and access to a Google Cloud project.

## Set up

Start in Major. The **Add Connector** dialog shows a command with a principal that is unique to your setup, and you need it in step 3.

1. Go to **Connectors** and click **Add Connector**.
2. Choose **Google Workspace Admin**. Keep the dialog open while you do the steps below.

> [!WARNING]
>
> Create the connector as the same person who opened the dialog. A different person gets a different principal, and the grant from step 3 will not match.

### 1. Create a service account

1. In the Google Cloud console, pick or create a project.
2. Go to **IAM & Admin > Service Accounts** and click **Create service account**. Give it a name and click **Done**. Don't grant it any roles, and don't create a key.
3. Open the service account. Copy its **Email** and its **Unique ID** (the numeric client ID). You need both later.

### 2. Enable the APIs

In the same project, go to **APIs & Services > Library** and enable all of these:

* **IAM Service Account Credentials API** (lets Major act as the service account)
* **Admin SDK API** (Directory, Data Transfer, and Reports)
* **Gmail API**
* **Enterprise License Manager API**

Google checks these APIs in the service account's project, not in your Workspace. If one is missing, the connection test fails.

### 3. Grant Major access to the service account

Copy the `gcloud` command from the dialog in Major. Replace `SERVICE_ACCOUNT_EMAIL` with the service account's email, then run it. It looks like this:

```bash theme={null}
gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \
  --role=roles/iam.serviceAccountTokenCreator \
  --member="principal://iam.googleapis.com/projects/.../workloadIdentityPools/.../subject/wsa-..."
```

To use the console instead, open the service account, go to **Principals with access**, and click **Grant access**. Paste the `principal://...` value as the new principal and choose the **Service Account Token Creator** role.

The principal can act only as this service account. It has no access to anything else in your project. IAM changes can take a minute or two to apply.

### 4. Authorize domain-wide delegation

A super admin does this in the [Google Admin console](https://admin.google.com):

1. Go to **Security > Access and data control > API controls**.
2. Click **Manage Domain Wide Delegation**, then **Add new**.
3. Paste the service account's numeric client ID from step 1.
4. In **OAuth scopes**, paste this comma-separated list:

```
https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.directory.user.security,https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/admin.directory.group.member,https://www.googleapis.com/auth/admin.directory.orgunit,https://www.googleapis.com/auth/admin.directory.device.mobile.action,https://www.googleapis.com/auth/admin.datatransfer,https://www.googleapis.com/auth/admin.reports.audit.readonly,https://www.googleapis.com/auth/apps.licensing,https://www.googleapis.com/auth/gmail.settings.basic,https://www.googleapis.com/auth/gmail.settings.sharing
```

5. Click **Authorize**. Google may ask you to sign in again. Afterwards, check that the client ID is in the list with 11 scopes.

Use this exact list. Major always requests these scopes, and Google rejects the request if any of them is not authorized. Changes usually apply in a few minutes, but can take up to 24 hours.

### 5. Finish in Major

1. In the dialog, enter the service account's email.
2. Enter the email of a super admin in your domain. Admin and licensing calls act as this person.
3. Click **Test connection**. The test lists one user in your domain as the admin. If it passes, every step above is correct.
4. Click **Create connector**.

## Which user each call acts as

Apps reach the Admin APIs through the [HTTP proxy](https://docs.major.build/learn/connectors/proxy-fetch.md). Agents and workflows can also use the connector's Gmail settings tools.

| Call | Acts as |
| - | - |
| Directory, Data Transfer, and Reports through the HTTP proxy (`https://admin.googleapis.com/admin/directory`, `/admin/datatransfer`, `/admin/reports`) | The admin email you entered |
| License Manager through the HTTP proxy (`https://licensing.googleapis.com/apps/licensing`) | The admin email you entered |
| Gmail settings tools (`get_auto_reply`, `set_auto_reply`, `get_forwarding`, `set_forwarding`, `list_delegates`, `add_delegate`, `remove_delegate`) | The user the tool call names |

The HTTP proxy rejects every other host and path. The connector cannot read, search, or send mail, and it cannot run Google Vault exports.

## Security

* Major signs a short-lived token with a key that never leaves AWS KMS. There is no service account key to leak or rotate.
* Only authorize the scope list above. Don't add more.
* Writes from agents and workflows need approval before they run.
* To cut off access, remove the client ID from **Manage Domain Wide Delegation**, or remove the Service Account Token Creator grant from the service account. Either one stops every call at once.

## Troubleshooting

The connection test names the step that failed.

| Error | Cause and fix |
| - | - |
| `service account ... was not found` | The service account email is wrong. Copy it again from the Cloud console. |
| `enable the IAM Service Account Credentials API` | Enable that API in the service account's project ([step 2](#2-enable-the-apis)). |
| `Google refused to sign as ...` | The grant from [step 3](#3-grant-major-access-to-the-service-account) is missing, is for a different principal, or has not applied yet. Check the principal and wait a minute. If someone else opened the dialog, create the connector as that person, or start again. |
| `Google rejected domain-wide delegation for ...` | The client ID or scopes are not authorized ([step 4](#4-authorize-domain-wide-delegation)). The client ID must be the service account's, and the scopes must match the list exactly. Wait a few minutes after a change. |
| `the admin directory API refused ...` | Google's reason follows in the message. Usually the admin email is not a super admin, or the Admin SDK API is not enabled in the service account's project. |


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