> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Connect Gmail, Google Calendar and Drive to your AI agents
URL: https://metorial.com/docs/platform/integrations/google-workspace

Publish Gmail, Google Calendar and Google Drive in a Metorial portal with per-user Google sign-in, your own Google Cloud OAuth client and read-only scopes.

---

In Metorial, Gmail, Google Calendar and Google Drive are separate integrations, each with Google OAuth sign-in, so you publish only the products people need. Each employee signs in with their own Google account, and the agent reads mail, events and files as that person. One Google Cloud OAuth client of your own can serve all three.

**What you'll learn**

* How an admin publishes the Google integrations and how an employee connects
* Which scopes each integration can request, and which ones are read-only
* How to use your own Google Cloud OAuth client

**Before you start**

* A [portal](https://metorial.com/docs/platform/workforce/portals) with at least one access group
* A Google account for each person who will connect
* To use your own OAuth client: a Google Cloud project you can edit

## Sign-in method

Each of the three integrations has one method: Google OAuth. Metorial asks Google for offline access, so the connection keeps working after the person closes the browser. There is no API key or service account method.

## Admin: publish the Google integrations

### In the dashboard

#### 1. Open Shared Resources

Open **Workforce**, choose the portal, and select **Shared Resources** under **Access**.

#### 2. Share each product

Select **Share a Resource**, then **New Integration**, and choose Gmail. For how members connect, choose **Each person connects**. Repeat for Google Calendar and Google Drive.

#### 3. Choose who gets them

Add the access groups that should see each one. You can give Calendar to everyone and Gmail to a smaller group.

### With the CLI

The CLI cannot create the per-user integrations. Once they exist, list who has them:

```bash
metorial-admin portals access list <portal-id> --type provider_template --search google
```

## Employee: connect your Google account

### In the portal

#### 1. Open the integration

Sign in to your portal and open Gmail, Google Calendar or Google Drive.

#### 2. Authenticate

Under **Quick setup**, select **Authenticate**. A Google tab opens. Choose your account and allow the permissions listed.

#### 3. Confirm

The status changes to **Configured**. Connect each Google product you need. They are separate connections.

### With the CLI

```bash
metorial catalog search gmail
metorial setup <catalog-item-id>
```

## Scopes

Google scopes are full URLs that start with `https://www.googleapis.com/auth/`. The tables show the last part.

| Gmail                      | Access                                  |
| -------------------------- | --------------------------------------- |
| `gmail.readonly`           | Read messages and settings              |
| `gmail.send`               | Send only                               |
| `gmail.compose`            | Create drafts and send                  |
| `gmail.modify`             | Read, send, and change labels and state |
| `gmail.labels`             | Manage labels                           |
| `https://mail.google.com/` | Full access, including permanent delete |

| Google Calendar            | Access                       |
| -------------------------- | ---------------------------- |
| `calendar.readonly`        | Read all calendars           |
| `calendar.events.readonly` | Read events                  |
| `calendar.events`          | Read and change events       |
| `calendar.freebusy`        | See free and busy times only |
| `calendar`                 | Full access                  |

| Google Drive              | Access                                                  |
| ------------------------- | ------------------------------------------------------- |
| `drive.readonly`          | Read all files                                          |
| `drive.metadata.readonly` | Read file names and properties, not content             |
| `drive.file`              | Only files the app created or the person opened with it |
| `drive`                   | Full access                                             |

Each integration offers more scopes than listed here, for example Gmail settings and Calendar sharing. You choose the set in the **Scopes** picker when you create your own auth credentials. For a read-only setup, allow the scopes under **Read-Only Scopes** and reject the rest.

Google classifies many Gmail and Drive scopes as sensitive or restricted. If your Google Cloud app is for use only inside your Google Workspace organization, those scopes need no review by Google.

## Use your own Google Cloud OAuth client

### 1. Start the credentials in Metorial

In the dashboard, select **Settings**, then **Organization Settings**. Under **Integrations and MCP**, select **Provider Auth**, then **Create Auth Credentials**. Choose Gmail and copy the **Redirect URI**.

### 2. Enable the APIs

In the Google Cloud console, go to **APIs & Services**, **Library**, **Google Workspace**. Open the Gmail API and click **Enable**. Do the same for the Calendar API and the Drive API.

### 3. Configure consent

Go to **Google Auth platform**, **Branding**. If it is not configured yet, click **Get Started**, enter an app name and support email, and under **Audience** select the user type. Choose internal when only people in your Google Workspace organization will connect.

### 4. Create the client

Go to **Google Auth platform**, **Clients** and click **Create Client**. For **Application type**, choose **Web application**. Under **Authorized redirect URIs**, click **Add URI** and paste the redirect URI from Metorial. Click **Create**, then copy the client ID and client secret. Google shows the secret only at this point.

### 5. Finish in Metorial

Enter a **Name**, the **Client ID** and the **Client Secret**, select scopes, and select **Create**. Create credentials for Google Calendar and Google Drive the same way. You can reuse the same Google client: add each redirect URI Metorial shows to its **Authorized redirect URIs**.

Google's own steps are in [Enable Google Workspace APIs](https://developers.google.com/workspace/guides/enable-apis), [Configure the OAuth consent screen](https://developers.google.com/workspace/guides/configure-oauth-consent) and [Create access credentials](https://developers.google.com/workspace/guides/create-credentials).

## Make the connection read-only

After you narrow the scopes, open the integration's **Tool Filters** and set the write and destructive tool groups to **Reject**. For Gmail, that keeps `search_messages` and `get_message` and removes `send_email` and the two permanent delete tools. See [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions).

## Check it worked

```bash
metorial list gmail
metorial tools <integration-id>
metorial call <integration-id> search_messages -d '{"query": "is:unread"}'
```

## Troubleshooting

**`redirect_uri_mismatch`**

Google returns this error when the redirect URI in the request is not listed on the OAuth client. Copy the **Redirect URI** from Metorial again and add it to **Authorized redirect URIs** exactly as shown.

## Next steps

* [Create custom OAuth credentials](https://metorial.com/docs/platform/integrations/create-custom-oauth-credentials)
* [Per-user OAuth](https://metorial.com/docs/platform/guides/per-user-oauth)
* [Connect an app from the terminal](https://metorial.com/docs/platform/cli/connect-an-app)
* [Call a tool from the terminal](https://metorial.com/docs/platform/cli/call-a-tool)