Skip to content

Latest commit

 

History

History
206 lines (176 loc) · 10.6 KB

File metadata and controls

206 lines (176 loc) · 10.6 KB
title Google Service Accounts
description Set up Google service accounts with domain-wide delegation for Gmail, Sheets, Drive, Calendar, and other Google services

import { Callout } from 'fumadocs-ui/components/callout' import { Step, Steps } from 'fumadocs-ui/components/steps' import { Image } from '@/components/ui/image' import { FAQ } from '@/components/ui/faq'

Google service accounts with domain-wide delegation let your workflows access Google APIs on behalf of users in your Google Workspace domain — without requiring each user to complete an OAuth consent flow. This is ideal for automated workflows that need to send emails, read spreadsheets, or manage files across your organization.

Prerequisites

Before adding a service account to Sim, you need to configure it in the Google Cloud Console and Google Workspace Admin Console.

1. Create a Service Account in Google Cloud

Go to the [Google Cloud Console](https://console.cloud.google.com/) and select your project (or create one) Navigate to **IAM & Admin** → **Service Accounts** Click **Create Service Account**, give it a name and description, then click **Create and Continue**
<div className="flex justify-center">
  <Image
    src="/static/credentials/gcp-create-service-account.png"
    alt="Google Cloud Console — Create service account form"
    width={700}
    height={500}
    className="my-4"
  />
</div>
Skip the optional role and user access steps and click **Done** Click on the newly created service account, go to the **Keys** tab, and click **Add Key** → **Create new key** Select **JSON** as the key type and click **Create**. A JSON key file will download — keep this safe
<div className="flex justify-center">
  <Image
    src="/static/credentials/gcp-create-private-key.png"
    alt="Google Cloud Console — Create private key dialog with JSON selected"
    width={700}
    height={400}
    className="my-4"
  />
</div>
The JSON key file contains your service account's private key. Treat it like a password — do not commit it to source control or share it publicly.

2. Enable the Required APIs

In the Google Cloud Console, go to APIs & ServicesLibrary and enable the APIs for the services your workflows will use. See the scopes reference below for the full list of APIs by service.

3. Set Up Domain-Wide Delegation

In the Google Cloud Console, go to **IAM & Admin** → **Service Accounts**, click on your service account, and copy the **Client ID** (the numeric ID, not the email) Open the [Google Workspace Admin Console](https://admin.google.com/) and navigate to **Security** → **Access and data control** → **API controls** Click **Manage Domain Wide Delegation**, then click **Add new** Paste the **Client ID** from your service account, then add the OAuth scopes for the services your workflows need. Copy the full scope URLs from the [scopes reference](#scopes-reference) below — only authorize scopes for services you plan to use.
<div className="flex justify-center">
  <Image
    src="/static/credentials/gcp-add-client-id.png"
    alt="Google Workspace Admin Console — Add a new client ID with OAuth scopes"
    width={350}
    height={300}
    className="my-4"
  />
</div>
Click **Authorize** Domain-wide delegation must be configured by a Google Workspace admin. If you are not an admin, send the Client ID and required scopes to your admin.

Scopes Reference

The table below lists every Google service that supports service account authentication in Sim, the API to enable in Google Cloud Console, and the delegation scopes to authorize. Copy the scope string for each service you need and paste it into the Google Workspace Admin Console.

Service API to Enable Delegation Scopes
GmailGmail API{'https://www.googleapis.com/auth/gmail.send'}
{'https://www.googleapis.com/auth/gmail.modify'}
{'https://www.googleapis.com/auth/gmail.labels'}
Google SheetsGoogle Sheets API, Google Drive API{'https://www.googleapis.com/auth/drive'}
Google DriveGoogle Drive API{'https://www.googleapis.com/auth/drive'}
Google DocsGoogle Docs API, Google Drive API{'https://www.googleapis.com/auth/drive'}
Google SlidesGoogle Slides API, Google Drive API{'https://www.googleapis.com/auth/drive'}
Google FormsGoogle Forms API, Google Drive API{'https://www.googleapis.com/auth/drive'}
{'https://www.googleapis.com/auth/forms.body'}
{'https://www.googleapis.com/auth/forms.responses.readonly'}
Google CalendarGoogle Calendar API{'https://www.googleapis.com/auth/calendar'}
Google ContactsPeople API{'https://www.googleapis.com/auth/contacts'}
Google AdsGoogle Ads API{'https://www.googleapis.com/auth/adwords'}
BigQueryBigQuery API{'https://www.googleapis.com/auth/bigquery'}
Google TasksTasks API{'https://www.googleapis.com/auth/tasks'}
Google VaultVault API, Cloud Storage API{'https://www.googleapis.com/auth/ediscovery'}
{'https://www.googleapis.com/auth/devstorage.read_only'}
Google GroupsAdmin SDK API{'https://www.googleapis.com/auth/admin.directory.group'}
{'https://www.googleapis.com/auth/admin.directory.group.member'}
Google MeetGoogle Meet API{'https://www.googleapis.com/auth/meetings.space.created'}
{'https://www.googleapis.com/auth/meetings.space.readonly'}
Vertex AIVertex AI API{'https://www.googleapis.com/auth/cloud-platform'}
You only need to enable APIs and authorize scopes for the services you plan to use. When authorizing multiple services, combine their scope strings with commas into a single entry in the Admin Console.

Adding the Service Account to Sim

Once Google Cloud and Workspace are configured, add the service account as a credential in Sim.

Open your workspace **Settings** and go to the **Integrations** tab Search for "Google Service Account" and click **Connect**
<div className="flex justify-center">
  <Image
    src="/static/credentials/integrations-service-account.png"
    alt="Integrations page showing Google Service Account"
    width={800}
    height={150}
    className="my-4"
  />
</div>
Paste the full contents of your JSON key file into the text area
Add Google Service Account dialog
Give the credential a display name (the service account email is used by default) Click **Save**

The JSON key file is validated for the required fields (type, client_email, private_key, project_id) and encrypted before being stored.

Using Delegated Access in Workflows

When you use a Google block (Gmail, Sheets, Drive, etc.) in a workflow and select a service account credential, an Impersonate User Email field appears below the credential selector.

Enter the email address of the Google Workspace user you want the service account to act as. For example, if you enter alice@yourcompany.com, the workflow will send emails from Alice's account, read her spreadsheets, or access her calendar — depending on the scopes you authorized.

Gmail block in a workflow showing the Impersonated Account field with a service account credential
The impersonated email must belong to a user in the Google Workspace domain where you configured domain-wide delegation. Impersonating external email addresses will fail.

<FAQ items={[ { question: "Can I use a service account without domain-wide delegation?", answer: "Yes, but it will only be able to access resources owned by the service account itself (e.g., spreadsheets shared directly with the service account email). Without delegation, you cannot impersonate users or access their personal data like Gmail." }, { question: "What happens if the impersonation email field is left blank?", answer: "The service account will authenticate as itself. This works for accessing shared resources (like a Google Sheet shared with the service account email) but will fail for user-specific APIs like Gmail." }, { question: "Can I use the same service account for multiple Google services?", answer: "Yes. A single service account can be used across Gmail, Sheets, Drive, Calendar, and other Google services — as long as the required API is enabled in Google Cloud and the corresponding scopes are authorized in the Workspace admin console." }, { question: "How do I rotate the service account key?", answer: "Create a new JSON key in the Google Cloud Console under your service account's Keys tab, then update the credential in Sim with the new key. Delete the old key from Google Cloud once the new one is working." }, { question: "Does the impersonated user need a Google Workspace license?", answer: "Yes. Domain-wide delegation only works with users who have a Google Workspace account in the domain. Consumer Gmail accounts (e.g., @gmail.com) cannot be impersonated." }, ]} />