Skip to content

Shared credential guides

Google service accounts

Set up Google service accounts with domain-wide delegation for Gmail, Sheets, Drive, Calendar, and other Google services

Google service accounts can access shared resources directly or impersonate a Google Workspace user through domain-wide delegation. This guide covers the JSON key, required APIs, delegation scopes, and credential setup in Sim.

For example, you could build a workflow that iterates through a list of employees, impersonates each one to read their Google Docs, and uploads the contents to a shared knowledge base — all without requiring any of those users to sign in.

For Google Cloud APIs such as BigQuery and Vertex AI, and for Gmail, Drive, Docs, Sheets, and Calendar through domain-wide delegation, you can skip the JSON key entirely: see Keyless Google Cloud access and Keyless domain-wide delegation.

Prerequisites

Create the service account and enable its APIs in Google Cloud. Configure the Google Workspace Admin Console only when using domain-wide delegation.

1. Create a service account in Google Cloud

  1. Go to the Google Cloud Console and select your project (or create one)

  2. Navigate to IAM & Admin → Service Accounts

  3. Click Create Service Account, give it a name and description, then click Create and Continue

  4. Skip the optional role and user access steps and click Done

  5. Click on the newly created service account, go to the Keys tab, and click Add Key → Create new key

  6. Select JSON as the key type and click Create. A JSON key file will download — keep this safe

2. Enable the required APIs

In the Google Cloud Console, go to APIs & Services → Library 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

  1. 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)

  2. Open the Google Workspace Admin Console and navigate to Security → Access and data control → API controls

  3. Click Manage Domain Wide Delegation, then click Add new

  4. 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 below — only authorize scopes for services you plan to use.

  5. Click Authorize

Domain-wide delegation requires a Google Workspace super administrator. Send that administrator the Client ID and required scopes. Changes can take up to 24 hours to propagate.

Scopes reference

The table below lists the Google Workspace and BigQuery services covered by this guide, 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.

ServiceAPI to EnableDelegation Scopes
GmailGmail APIhttps://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 APIhttps://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
Google DriveGoogle Drive APIhttps://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
Google DocsGoogle Docs API, Google Drive APIhttps://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
Google SlidesGoogle Slides API, Google Drive APIhttps://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
Google FormsGoogle Forms API, Google Drive APIhttps://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/forms.body
https://www.googleapis.com/auth/forms.responses.readonly
Google CalendarGoogle Calendar APIhttps://www.googleapis.com/auth/calendar
Google ContactsPeople APIhttps://www.googleapis.com/auth/contacts
BigQueryBigQuery APIhttps://www.googleapis.com/auth/bigquery
Google TasksTasks APIhttps://www.googleapis.com/auth/tasks
Google VaultVault API, Cloud Storage APIhttps://www.googleapis.com/auth/ediscovery
https://www.googleapis.com/auth/devstorage.read_only
Google GroupsAdmin SDK APIhttps://www.googleapis.com/auth/admin.directory.group
https://www.googleapis.com/auth/admin.directory.group.member
Google MeetGoogle Meet APIhttps://www.googleapis.com/auth/meetings.space.created
https://www.googleapis.com/auth/meetings.space.readonly

The Google Groups entry covers Directory API actions. Get Settings and Update Settings require the Groups Settings API and its https://www.googleapis.com/auth/apps.groups.settings scope, which Sim's current Google Groups scope list does not request. See the Google Groups reference for this compatibility limit.

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.

Add the service account to Sim

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

  1. Open Integrations from your workspace sidebar

  2. Search for "Google Drive" and open it, or use another Google integration that supports service-account credentials. Click Add to Sim and choose Add service account

  3. Paste the full contents into JSON key, or use Or upload a file to select the JSON key file.

  4. Give the credential a display name (the service account email is used by default)

  5. Click Add service account

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

Use delegated access in workflows

When you use a Google block (Gmail, Sheets, Drive, etc.) in a workflow and select a service account credential, an Impersonated Account 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.

Shared access and key rotation

Leave Impersonated Account blank to authenticate as the service account itself. Share supported resources, such as a Sheet, with its service-account email. This does not grant access to a user’s Gmail. A Google Cloud IAM role alone does not grant access to Google Workspace files or mailbox data.

Domain-wide delegation requires a Google Workspace super administrator. It authorizes impersonation within that Workspace domain, subject to the authorized scopes and the impersonated user’s access. Consumer Gmail accounts and users outside that domain cannot be impersonated. Access also depends on the license required by the target service. See Google’s service-account authorization guide.

Google Ads never uses domain-wide delegation: add the service account's email as a user in the Google Ads account (Admin > Access and security); it signs in as itself. Enable the Google Ads API in the project that owns the service account; that project's Google Ads API access level applies. See Google Ads.

A credential can serve multiple supported Google services when their APIs and scopes are configured. To rotate its key, create a replacement JSON key, update the credential in Sim, verify access, then delete the old key in Google Cloud.

Keyless Google Cloud access

A Google service account credential can also be keyless: Sim stores no key. Instead, your Google Cloud project trusts Sim through Workload Identity Federation. On each run, Sim signs a short-lived token for this credential's own subject, exchanges it at Google's Security Token Service for a federated token, and uses that to impersonate your service account. The service account's IAM roles decide what workflows can do, exactly as with a JSON key.

  1. In the Google Cloud Console, enable the IAM, Resource Manager, Service Account Credentials, and Security Token Service APIs in the project that will hold the workload identity pool, and note its project number (on the project's Dashboard; it's numeric, not the project ID).

  2. Create or pick a service account, and grant it the roles your workflows need (for example, BigQuery Data Viewer and BigQuery Job User, or Vertex AI User). No key is needed.

  3. In Sim, open the Google BigQuery integration, choose Add service account, and set Authentication to Workload Identity Federation (keyless, via Sim OIDC). Enter the project number, a pool ID and provider ID (4 to 32 lowercase letters, digits, or hyphens, not starting with gcp-), and the service account email (name@project-id.iam.gserviceaccount.com; user-managed service account only, so default accounts such as …@developer.gserviceaccount.com are refused).

  4. The dialog shows the Issuer, Audience, and Subject, and three gcloud commands with your values filled in. Run them in that project. They run against the project number you entered and create the pool, an OIDC provider for Sim's issuer with the attribute mapping google.subject=assertion.sub and an attribute condition that accepts only this credential's subject, and grant that subject roles/iam.workloadIdentityUser on the service account. If the pool already exists, skip the first command:

    Code
    gcloud iam workload-identity-pools create POOL_ID \
        --project="PROJECT_NUMBER" \
        --location="global" \
        --display-name="Sim"
    
    gcloud iam workload-identity-pools providers create-oidc PROVIDER_ID \
        --project="PROJECT_NUMBER" \
        --location="global" \
        --workload-identity-pool="POOL_ID" \
        --issuer-uri="ISSUER" \
        --attribute-mapping="google.subject=assertion.sub" \
        --attribute-condition="assertion.sub=='SUBJECT'"
    
    gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_EMAIL \
        --project="PROJECT_NUMBER" \
        --role="roles/iam.workloadIdentityUser" \
        --member="principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/subject/SUBJECT"

    By default the provider sets no allowed audiences, so it accepts its own resource name, which Sim's token carries as its aud.

  5. Save in Sim. Sim exchanges a token at STS and impersonates the service account; a token from that step proves the setup works. It also checks that a subject no credential holds can't impersonate the service account, so only this credential can use it. New IAM bindings can take a few minutes to apply; if saving fails right after you run the commands, wait and try again.

Custom audience

To pin the provider to a value of your own instead of its resource name, enter it under Audience (up to 255 letters, digits, and . _ ~ : / ? # @ & + = % -). Sim's token then carries that value as its aud, and the setup commands add it to the provider's allowed audiences, which then accept only the listed values:

Code
gcloud iam workload-identity-pools providers create-oidc PROVIDER_ID \
    ... \
    --allowed-audiences="AUDIENCE"

For an existing provider, run gcloud iam workload-identity-pools providers update-oidc PROVIDER_ID --project="PROJECT_NUMBER" --location="global" --workload-identity-pool="POOL_ID" --allowed-audiences="AUDIENCE" before reconnecting the credential with the new audience. Sim still exchanges the token at STS for the provider itself. To go back to the default, clear Audience and remove the allowed audiences from the provider (or add its resource name, https://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID). Another cloud's default audience, such as sts.amazonaws.com, is refused.

Each keyless credential has its own subject; reconnecting keeps it by default so your provider and binding keep working. Use one provider per credential (a pool can hold many). Keyless credentials are available for workspace credentials, not organization credentials. Sim uses impersonation rather than direct federated access because some Google Cloud APIs don't accept federated tokens, and impersonation keeps the same identity a JSON key would use.

Self-hosted deployments need WORKLOAD_IDENTITY_SIGNING_KEY set and an https issuer Google can reach over the public internet. See AWS credentials.

From the API or CLI

Run sim credentials keyless-subject google-service-account, trust the printed subject as above, then add projectNumber, poolId, providerId, and serviceAccountEmail (and optionally audience) to its keylessConfig and pass it to sim credentials create google-service-account. See the CLI credentials reference for the full two-step example; the proof expires after 24 hours and works only for the user who requested it. Sim holds an unsaved subject for you for 30 days, so a trust configuration that takes longer to apply still works: reopening the connect dialog offers the same subject, and --subject <subject> renews its proof from the CLI. For domain-wide delegation, also add "delegation": {"user": "alice@yourcompany.com", "services": ["gmail", "google-drive"]}, listing any of gmail, google-drive, google-docs, google-sheets, and google-calendar.

Keyless domain-wide delegation

A keyless credential can also act as one Google Workspace user in Gmail, Google Drive, Google Docs, Google Sheets, and Google Calendar, without a JSON key. Google's domain-wide delegation guidance recommends this: on each run, Sim exchanges its token at STS as above, then asks the IAM Service Account Credentials API to sign the same delegation assertion a JSON key would sign, with your user as its subject, and exchanges it at Google's OAuth token endpoint.

  1. Set up the keyless credential as above, from the Gmail, Google Drive, Google Docs, Google Sheets, or Google Calendar integration. Under Domain-wide delegation, choose the services the credential may use, and enter the Workspace user it acts as.

  2. Grant the subject roles/iam.serviceAccountTokenCreator on the service account instead of roles/iam.workloadIdentityUser; the setup commands do this when delegation is on. Signing needs the iam.serviceAccounts.signJwt permission, which Service Account Token Creator includes and Workload Identity User does not. Token Creator also grants permissions Sim doesn't use, such as iam.serviceAccounts.signBlob; for least privilege, grant a custom role with just iam.serviceAccounts.signJwt and iam.serviceAccounts.getAccessToken (the second keeps BigQuery and Vertex AI working with the same credential).

  3. In the Google Cloud console, enable each service's API (see the scopes reference) in the project that owns the service account, and copy the service account's numeric Unique ID (its OAuth 2 client ID).

  4. Have a Google Workspace super administrator authorize that client ID in the Admin console under Security → Access and data control → API controls → Manage Domain Wide Delegation, for the scopes the dialog lists under Scopes to authorize.

  5. Save in Sim. For each service, Sim signs in as the Workspace user and makes one read (the Gmail profile, Drive's account details, or the first calendar in the calendar list), so a missing role or authorization, or a disabled Gmail, Drive, or Calendar API, shows up now rather than in a run. Google Docs and Google Sheets use Drive's scopes and are checked through the Drive API only: enable the Google Docs API and Google Sheets API yourself, since a disabled one shows up only in a run.

Troubleshooting keyless access

  • "Google Cloud refused Sim's token for this workload identity provider": the project number, pool ID, or provider ID doesn't match; the provider is disabled or uses a different issuer; its allowed audiences don't accept the credential's audience (with the default, it needs none set, or its own resource name among them; with a custom audience, that value must be listed); or its attribute condition doesn't allow this credential's subject.
  • "Google Cloud could not fetch the signing keys from Sim's issuer": the issuer isn't reachable over public HTTPS (self-hosted deployments).
  • "The service account … does not let this credential impersonate it": run the add-iam-policy-binding command with the exact member shown, and enable the IAM Service Account Credentials API.
  • "This service account also trusts other Sim credentials": remove any principalSet binding for the pool from the service account and keep the attribute condition.
  • "… does not let this credential sign for it, which domain-wide delegation needs": grant roles/iam.serviceAccountTokenCreator on the service account to the exact principal://…/subject/SUBJECT member, and enable the IAM Service Account Credentials API.
  • "Google Workspace has not authorized this service account's domain-wide delegation": authorize the service account's client ID for every scope the dialog lists in the Admin console. New authorizations can take a while to apply.
  • "Your Google Workspace admin policies block one or more of these scopes": a Workspace administrator must allow the service account's client ID under API controls, third-party app access.
  • "Google reports the service account … is disabled" (or "was deleted"): enable the service account in Google Cloud under IAM & Admin > Service Accounts, or restore a deleted one within 30 days.
  • "Google refused to sign in as …": the address isn't an active user in your Workspace domain.
  • "… but the Gmail API refused the request" (or Drive, Calendar): enable that API in the project that owns the service account, and check the user has the service.
  • A block fails with "This credential cannot be used here": the block needs scopes the credential's delegation doesn't authorize (or it isn't BigQuery or Vertex AI), or it sets an Impersonated Account other than the credential's Workspace user. Reconnect the credential with that block's service, or use a JSON key.

A keyless credential is used only for the scopes listed under Scopes to authorize, and Sim refuses anything else before contacting Google. Like Google, Sim authorizes by scope, not by block: Drive, Docs, and Sheets share those scopes, so a credential delegated for any of them also serves the other two and their file pickers, which ask for read-only Drive access that the authorized drive scope covers. Read-only Gmail access, which the Gmail label picker and knowledge base connector ask for, is served with the authorized gmail.modify scope, and the Google Calendar knowledge base connector's read-only events access with the authorized calendar scope. Knowledge base connectors that need other scopes, such as the admin directory scopes, need a JSON key.

Was this helpful?
Suggest an edit