About Google Workspace
Google Workspace (formerly G Suite) provides email, calendar, drive and directory services for organisations. Connecting Google Workspace to Serval lets you automate common admin tasks, enforce security policies and modify user data directly inside Serval workflows.What the Google Workspace integration enables
| Capability | Connection Method | Description |
|---|---|---|
| Access Management | OAuth or Service Account | Create, update, and manage users and their permissions |
| Automation workflows | OAuth or Service Account | Manage groups, and organizational data. Create aliases, manage settings, and more |
| Knowledge Base Sync | Service Account only | Automatically sync and index Google Drive content (Docs, Sheets, Slides) for semantic search |
| Gmail Delegation | Service Account only | Manage email delegation settings |
Choose your connection method
We offer two different configuration mechanisms for Google Workspace:- Standard OAuth integration:
- Simple integration process
- Suitable for basic user and group management
- No domain-wide delegation required
- Service Account integration:
- More manual configuration required
- Full control over scopes and permissions
- Required for advanced APIs (e.g., Gmail delegation APIs)
- Enables domain-wide delegation
.png?fit=max&auto=format&n=2yD3bPadWazatQgL&q=85&s=1c7856c9ac97472fee32f3fd823f815a)
Service Account Integration Setup
Step 1: Create Google Cloud Project and Service Account
- Navigate to console.cloud.google.com and login
- Create a new project:
- Click “Select a Project” → “New Project”
- Choose any name for your project
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=a90915c4a9c2a9d558dcd3d6acbd4e01)
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=91d606b4408fc34648dbe9f3924278e6)
- Create a service account:
- Search for “Service account” by selecting the search bar at the top of the page, or by typing ”/” to activate search.
- Select “Create service account”
- Provide a Service account name and account ID.
- All other fields are optional and you can select “Done” to complete Service account creation.
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=e03dbb94a331645bfeb5b9363f61bd84)
Step 2: Enable Required APIs
Critical: Enable the required APIs in your Google Cloud project:- Navigate to “APIs & Services” → “Library”
- Search for and select enable for the following APIs:
- Admin SDK API (required for user and group management)
- Gmail API (required for Gmail operations)
- Google Drive API (required for Drive file operations)
- Google Sheets API (required for Sheets operations)
- Note: API selection is customizable to your use case.
Step 3: Configure Service Account Permissions
Grant Serval permission to impersonate your service account:- Navigate to “IAM & Admin” → “Service Accounts” in your Google Cloud project
- Click on the service account you created in Step 1
- Go to the “Permissions” tab and click “Grant Access”
- Add the principal:
serval@serval-424322.iam.gserviceaccount.com - Assign the role: “Service Account Token Creator”
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=a61ee846a28e2827978bbdb9a8dd209a)
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=8b2bee711d4c539e754e2101b11d5e05)
Step 4: Configure Domain-Wide Delegation
-
Get your service account’s Unique ID / Client ID:
- Go to your service account → “Details” page
- Copy the “Unique ID” / “Client ID” (long numeric string, e.g.,
116634191637610572786)
-
Configure in Google Workspace Admin Console:
- Navigate to admin.google.com → “Security” → “Access and data control” → “API controls” → “Manage Domain Wide Delegation”
- Click “Add New”
- Enter your service account’s Unique ID / Client ID in the “Client ID” field
.png?fit=max&auto=format&n=2yD3bPadWazatQgL&q=85&s=e141d659fca85821222f364691d4d39d)
- Select and authorize scopes:
- We recommend using All Scopes for the full range of Serval capabilities. Use Minimal Scopes if you only need basic user and group management.
Having trouble with scopes or permissions? See Troubleshooting for common error messages and solutions.
- Paste the comma-separated scopes into the “OAuth scopes” field
- Click “Authorize”
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=6a7c6ebf01980d1000ab51bd0648bfe7)
Step 5: Organization Policies (Optional)
Only complete this step if you received domain restriction errors in Step 3.- Navigate to Google Cloud Console → Organization Policies
- Search for
iam.allowedPolicyMemberDomains - Select “Domain Restricted Sharing” → “Manage Policy”
- Select “Override Parent’s Policy” and “Merge with Parent”
- Click “Add a rule” → “Custom” → “Allow”
- Enter
C04gvbkucas the custom value - Save the policy
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=42c25cfd773ca92fd8e67a6defdf50f2)
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=2124a52933ed71f0cdb7aadb2e31c58a)
.png?fit=max&auto=format&n=muF_YomC37fBCG6k&q=85&s=55c415fe10191c9da1350982783113be)
- Request access from your Organization Administrator
- Contact your Google Cloud Administrator
- Use a different Google Cloud project where you have admin rights
Step 6: Complete Connection
Return to Serval to complete the integration:- Navigate to “Applications” → “Google Workspace” → “Connect” → “Service Account”
- Enter the required information:
- Google Workspace domain: Your organization’s domain (e.g.,
company.com) - Service Account email: Your service account’s email address
- Default subject: An admin user in your domain (e.g.,
admin@company.com) - Scopes: The comma-separated list from Step 4
- Google Workspace domain: Your organization’s domain (e.g.,
- Click “Submit”
Your Google Workspace integration is now ready to use!
Knowledge Base Sync
Once your Google Workspace integration is configured with the Drive API scopes, you can enable knowledge base synchronization to make your Google Drive content searchable within Serval.What Gets Synced
Serval automatically syncs and indexes the following Google Drive content types:- Google Docs - Full text content converted to markdown
- Google Sheets - Exported as CSV and converted to markdown tables
- Google Slides - Slide text content as markdown
- Folders - Folder hierarchy for organization (no content to index)
Not supported yet: - Files from other formats (PDF, Word, etc.) are not
currently synced - Comments and suggestions within documents - Revision
history
How Sync Works
Initial Sync:- Serval discovers all accessible Google Drive files and folders
- Downloads and converts supported file types to searchable markdown
- Creates embeddings for semantic search
- Maintains folder hierarchy for organization
- Serval automatically detects changes to synced files using the Drive Changes API
- Only modified files are re-downloaded and re-indexed
- The
drive.metadatascope enables efficient change detection
Required Scopes for Knowledge Base Sync
At minimum, you need these scopes for knowledge base functionality:Managing Your Knowledge Base
After enabling sync:- Navigate to your Google Workspace app in Serval
- Go to the “Knowledge Source” tab
- Click “Sync” to start an initial sync
- Monitor sync progress and view synced items
- Toggle individual items’ visibility to control what’s searchable
Sync frequency: Incremental syncs run automatically every few hours to
detect changes. You can manually trigger a sync at any time.
Troubleshooting
Common Setup Issues
If you encounter errors during setup, verify these configurations:| Component | Verification |
|---|---|
| APIs Enabled | Google Cloud Console → APIs & Services → Enabled APIs |
| Service Account Permissions | Service Account → Permissions → Verify serval@serval-424322.iam.gserviceaccount.com has “Token Creator” role |
| Domain-Wide Delegation | Google Workspace Admin Console → Security → API Controls → Verify Client ID is listed |
Error Messages and Solutions
”impersonate: status code 401: unauthorized_client”
Missing: Service account permissionsFix: Complete Step 3: Configure Service Account Permissions
”Admin SDK API has not been used in project [PROJECT_ID] before or it is disabled”
Missing: API enablementFix: Complete Step 2: Enable Required APIs
”Client is unauthorized to retrieve access tokens using this method”
Missing: Domain-wide delegationFix: Complete Step 4: Configure Domain-Wide Delegation
”Domain restricted sharing policy”
Missing: Organization policy configurationFix: Complete Step 5: Organization Policies
Knowledge Base Sync Issues
”Failed to list Drive files”
- Verify the
driveanddrive.metadatascopes are configured in domain-wide delegation - Check that the Drive API is enabled in your Google Cloud project
- Ensure your default subject user has access to the files you’re trying to sync
”No files synced” but files exist
- Check folder permissions — Serval can only sync files accessible to the default subject user
- Verify files are of supported types (Docs, Sheets, Slides)
- Check that files aren’t in the Trash
Slow initial sync
- Initial syncs can take time for large Drive accounts (hundreds of files)
- Consider using folder selection to limit scope
- Incremental syncs after the initial sync are much faster
Getting Help
If you continue to experience issues:- Verify all steps in the setup process are complete
- Wait 10-15 minutes for Google services to propagate changes
- Check that your default subject user has admin privileges in Google Workspace
Scope Reference
Below is a breakdown of what each Google API scope enables. Use this to decide which scopes are appropriate for your organization.Admin Directory
| Scope | Description |
|---|---|
admin.directory.user | Manage users in your domain |
admin.directory.group | Manage groups in your domain |
admin.directory.group.member | Manage group memberships |
admin.directory.domain.readonly | Read domain information |
apps.groups.settings | Manage group settings |
Gmail
| Scope | Description |
|---|---|
gmail.settings.basic | Manage basic Gmail settings |
gmail.settings.sharing | Manage Gmail delegation settings |
Calendar
| Scope | Description |
|---|---|
calendar | Full access to Google Calendar |
Drive and Knowledge Base
| Scope | Description |
|---|---|
drive | Full access to Google Drive files. Required for Knowledge Base sync. |
drive.metadata | Access to file metadata for change detection. Required for incremental sync. |
Sheets
| Scope | Description |
|---|---|
spreadsheets | Full access to Google Sheets |
spreadsheets.readonly | Read-only access to Google Sheets |
Platform
| Scope | Description |
|---|---|
cloud-platform | Required. Enables Serval to impersonate your service account. |
All scopes are prefixed with
https://www.googleapis.com/auth/. For example, admin.directory.user refers to https://www.googleapis.com/auth/admin.directory.user.
