Google Workspace Domain-Wide Delegation Setup
This guide will help you set up Domain-Wide Delegation of Authority so your service account can invite attendees to calendar events.
Prerequisites
- Google Workspace Admin access
- Google Cloud Console access
- Service account already created and configured
Step 1: Enable Domain-Wide Delegation in Google Cloud Console
- Go to Google Cloud Console: https://console.cloud.google.com/
- Select your project (the one with your service account)
- Navigate to: IAM & Admin → Service Accounts
- Find your service account (the one you're using for the calendar API)
- Click on the service account to open its details
- Go to the "Details" tab
- Click "Show domain-wide delegation"
- Check "Enable Google Workspace Domain-wide Delegation"
- Note down the "Client ID" (you'll need this for the next step)
Step 2: Configure Domain-Wide Delegation in Google Workspace Admin
- Go to Google Workspace Admin Console: https://admin.google.com/
- Navigate to: Security → API Controls
- Click "Domain-wide delegation"
- Click "Add new"
- Enter the Client ID from Step 1
- Add OAuth Scopes (copy and paste these exactly):
https://www.googleapis.com/auth/calendar,https://www.googleapis.com/auth/calendar.events,https://www.googleapis.com/auth/calendar.settings.readonly,https://www.googleapis.com/auth/calendar.freebusy - Click "Authorize"
OAuth Scopes Explained:
calendar- Full calendar access (create, read, update, delete events)calendar.events- Event management (create, update, delete events)calendar.settings.readonly- Read calendar settings (working hours, timezone)calendar.freebusy- Access free/busy information for availability checking
Note: Google Meet conference data is automatically included with the
calendar scope - no separate conference scope is needed.Step 3: Update Environment Variables
Make sure your
.env.local file has the correct service account email:GOOGLE_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
GOOGLE_CALENDAR_ID=carl@cascadiamarquee.comStep 4: Test the Setup
- Restart your development server to pick up the new authentication
- Submit a test booking using your Gmail address
- Check the server logs for successful event creation
- Check your Google Calendar to verify:
- Event appears with Google Meet link
- Attendees are listed
- You receive a calendar invite
Troubleshooting
Error: "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority"
- Verify that Domain-Wide Delegation is enabled in Google Cloud Console
- Verify that the Client ID is correctly added in Google Workspace Admin
- Verify that the OAuth scopes are exactly as specified above
- Make sure you're using the correct Google Workspace admin email in the
subjectfield
Error: "Insufficient Permission"
- Verify that the service account has the correct scopes
- Verify that the Google Workspace admin email is correct
- Check that the service account has access to the calendar
No Google Meet Link Generated
- Verify that
conferenceDataVersion: 1is included in the API call - Check that the
conferenceDataobject is properly formatted - Ensure the calendar supports Google Meet (most Google Workspace calendars do)
Security Notes
- Domain-Wide Delegation gives the service account broad access to your Google Workspace
- Only enable this for trusted service accounts
- Regularly review and audit the permissions
- Consider using more specific scopes if possible
What This Enables
With Domain-Wide Delegation properly configured, your service account can:
- ✅ Create calendar events with attendees
- ✅ Send automatic calendar invites
- ✅ Generate Google Meet links
- ✅ Access shared calendars
- ✅ Manage event permissions
Next Steps
Once setup is complete:
- Test with a real booking
- Verify calendar invites are received
- Confirm Google Meet links work
- Remove debug logging for production
- Re-enable email domain restrictions if desired