Google Calendar Sync
Google Calendar Sync lets a frontend-token user connect one or more Google accounts, import their Google calendars, and load the synced calendars through the normal Schedule X config endpoint.
Sync requires the GoogleCalendarSync entitlement for the organization.
Browser Flow
Section titled “Browser Flow”Use ScheduleXBrowserClient with a frontend token. Do not use the organization API token in the browser.
const client = new ScheduleXBrowserClient({ token: frontendToken.token,})
const { url } = await client.integrations.googleCalendar.getConnectUrl({ returnUrl: window.location.href,})
window.location.assign(url)After Google redirects back to your returnUrl, load the connected calendars and enable sync:
const providerCalendars = await client.integrations.googleCalendar.listProviderCalendars()
await client.integrations.googleCalendar.enableAllProviderCalendars()
const config = await client.scheduleX.getCalendarAppConfig()listProviderCalendars() returns calendars from all active Google account connections for the current frontend-token user. Each item includes connectionId and providerEmail so you can show which Google account it belongs to.
Selective Sync
Section titled “Selective Sync”To let users choose specific calendars:
const connections = await client.integrations.googleCalendar.listConnections()const calendars = await client.integrations.googleCalendar.listProviderCalendars( connections[0].id)
await client.integrations.googleCalendar.enableCalendarSync( connections[0].id, calendars[0].id, { name: calendars[0].name })Use getSyncStatus() to show sync state:
const status = await client.integrations.googleCalendar.getSyncStatus()Statuses are PendingInitialSync, Syncing, Synced, Error, or Disabled.
- Synced calendars appear in
getCalendarAppConfig()like other Schedule X calendars. - Event changes are processed asynchronously by the sync worker.
- Disconnecting a Google account stops future sync for that connection.