-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Feat/google service account #3828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
TheodoreSpeaks
wants to merge
9
commits into
staging
Choose a base branch
from
feat/google-service-account
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e0da285
feat(auth): allow google service account
7ec0259
Add gmail support for google services
e8717bb
Refresh creds on typing in impersonated email
370148a
Switch to adding subblock impersonateUserEmail conditionally
ce345b9
Directly pass subblock for impersonateUserEmail
336c3ef
Fix lint
b32a388
Update documentation for google service accounts
299998c
Merge branch 'staging' into feat/google-service-account
6241ca9
Fix lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
206 changes: 206 additions & 0 deletions
206
apps/docs/content/docs/en/credentials/google-service-account.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| --- | ||
| 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 | ||
|
|
||
| <Steps> | ||
| <Step> | ||
| Go to the [Google Cloud Console](https://console.cloud.google.com/) and select your project (or create one) | ||
| </Step> | ||
| <Step> | ||
| Navigate to **IAM & Admin** → **Service Accounts** | ||
| </Step> | ||
| <Step> | ||
| 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> | ||
| </Step> | ||
| <Step> | ||
| Skip the optional role and user access steps and click **Done** | ||
| </Step> | ||
| <Step> | ||
| Click on the newly created service account, go to the **Keys** tab, and click **Add Key** → **Create new key** | ||
| </Step> | ||
| <Step> | ||
| 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> | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| <Callout type="warn"> | ||
| 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. | ||
| </Callout> | ||
|
|
||
| ### 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](#scopes-reference) below for the full list of APIs by service. | ||
|
|
||
| ### 3. Set Up Domain-Wide Delegation | ||
|
|
||
| <Steps> | ||
| <Step> | ||
| 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) | ||
| </Step> | ||
| <Step> | ||
| Open the [Google Workspace Admin Console](https://admin.google.com/) and navigate to **Security** → **Access and data control** → **API controls** | ||
| </Step> | ||
| <Step> | ||
| Click **Manage Domain Wide Delegation**, then click **Add new** | ||
| </Step> | ||
| <Step> | ||
| 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> | ||
| </Step> | ||
| <Step> | ||
| Click **Authorize** | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| <Callout type="info"> | ||
| 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. | ||
| </Callout> | ||
|
|
||
| ### 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. | ||
|
|
||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th className="whitespace-nowrap">Service</th> | ||
| <th className="whitespace-nowrap">API to Enable</th> | ||
| <th>Delegation Scopes</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr><td>Gmail</td><td>Gmail API</td><td><code>{'https://www.googleapis.com/auth/gmail.send'}</code><br/><code>{'https://www.googleapis.com/auth/gmail.modify'}</code><br/><code>{'https://www.googleapis.com/auth/gmail.labels'}</code></td></tr> | ||
| <tr><td>Google Sheets</td><td>Google Sheets API, Google Drive API</td><td><code>{'https://www.googleapis.com/auth/drive'}</code></td></tr> | ||
| <tr><td>Google Drive</td><td>Google Drive API</td><td><code>{'https://www.googleapis.com/auth/drive'}</code></td></tr> | ||
| <tr><td>Google Docs</td><td>Google Docs API, Google Drive API</td><td><code>{'https://www.googleapis.com/auth/drive'}</code></td></tr> | ||
| <tr><td>Google Slides</td><td>Google Slides API, Google Drive API</td><td><code>{'https://www.googleapis.com/auth/drive'}</code></td></tr> | ||
| <tr><td>Google Forms</td><td>Google Forms API, Google Drive API</td><td><code>{'https://www.googleapis.com/auth/drive'}</code><br/><code>{'https://www.googleapis.com/auth/forms.body'}</code><br/><code>{'https://www.googleapis.com/auth/forms.responses.readonly'}</code></td></tr> | ||
| <tr><td>Google Calendar</td><td>Google Calendar API</td><td><code>{'https://www.googleapis.com/auth/calendar'}</code></td></tr> | ||
| <tr><td>Google Contacts</td><td>People API</td><td><code>{'https://www.googleapis.com/auth/contacts'}</code></td></tr> | ||
| <tr><td>Google Ads</td><td>Google Ads API</td><td><code>{'https://www.googleapis.com/auth/adwords'}</code></td></tr> | ||
| <tr><td>BigQuery</td><td>BigQuery API</td><td><code>{'https://www.googleapis.com/auth/bigquery'}</code></td></tr> | ||
| <tr><td>Google Tasks</td><td>Tasks API</td><td><code>{'https://www.googleapis.com/auth/tasks'}</code></td></tr> | ||
| <tr><td>Google Vault</td><td>Vault API, Cloud Storage API</td><td><code>{'https://www.googleapis.com/auth/ediscovery'}</code><br/><code>{'https://www.googleapis.com/auth/devstorage.read_only'}</code></td></tr> | ||
| <tr><td>Google Groups</td><td>Admin SDK API</td><td><code>{'https://www.googleapis.com/auth/admin.directory.group'}</code><br/><code>{'https://www.googleapis.com/auth/admin.directory.group.member'}</code></td></tr> | ||
| <tr><td>Google Meet</td><td>Google Meet API</td><td><code>{'https://www.googleapis.com/auth/meetings.space.created'}</code><br/><code>{'https://www.googleapis.com/auth/meetings.space.readonly'}</code></td></tr> | ||
| <tr><td>Vertex AI</td><td>Vertex AI API</td><td><code>{'https://www.googleapis.com/auth/cloud-platform'}</code></td></tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| <Callout type="info"> | ||
| 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. | ||
| </Callout> | ||
|
|
||
| ## Adding the Service Account to Sim | ||
|
|
||
| Once Google Cloud and Workspace are configured, add the service account as a credential in Sim. | ||
|
|
||
| <Steps> | ||
| <Step> | ||
| Open your workspace **Settings** and go to the **Integrations** tab | ||
| </Step> | ||
| <Step> | ||
| 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> | ||
| </Step> | ||
| <Step> | ||
| Paste the full contents of your JSON key file into the text area | ||
| <div className="flex justify-center"> | ||
| <Image | ||
| src="/static/credentials/add-service-account.png" | ||
| alt="Add Google Service Account dialog" | ||
| width={350} | ||
| height={420} | ||
| className="my-6" | ||
| /> | ||
| </div> | ||
| </Step> | ||
| <Step> | ||
| Give the credential a display name (the service account email is used by default) | ||
| </Step> | ||
| <Step> | ||
| Click **Save** | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| 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. | ||
|
|
||
| <div className="flex justify-center"> | ||
| <Image | ||
| src="/static/credentials/workflow-impersonated-account.png" | ||
| alt="Gmail block in a workflow showing the Impersonated Account field with a service account credential" | ||
| width={800} | ||
| height={350} | ||
| className="my-4" | ||
| /> | ||
| </div> | ||
|
|
||
| <Callout type="warn"> | ||
| 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. | ||
| </Callout> | ||
|
|
||
| <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." }, | ||
| ]} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "title": "Credentials", | ||
| "pages": ["index", "google-service-account"], | ||
| "defaultOpen": false | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.8 KB
apps/docs/public/static/credentials/workflow-impersonated-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets get rid of the else block and condense the nested ifs here