All connectors
Google Calendar
OfficialCalendar
Google Calendar
Let agents see what is on your calendar and help plan your time.
- Review upcoming events across your calendars, including recurring ones.
- Find free time with busy/free availability.
- With Write access: create, update, move and cancel events, invite attendees and add Google Meet links.
Read access cannot change your calendars or notify attendees.
Setup instructions
Setup instructions
Connect your Google account
- Choose the level for Access:
- Read to let agents read without changing anything.
- Write to also let agents create, change and cancel events.
- Select Continue with Google, choose your account, and approve the permissions Google lists. If Google shows a checkbox per permission, tick them all: Houston refuses a partial grant.
Each Google Calendar connection asks only for its own permissions, so connecting Google Calendar does not grant access to your other Google services.
Advanced: changing access and troubleshooting
- To change the access level, edit the connection and connect with Google again. Google then asks for the new set of permissions.
- To revoke access, remove the connection in Houston, or remove Houston from your Google Account's third-party connections.
- Google Workspace administrators can block third-party apps. If Google refuses the connection, ask your administrator to allow Houston.
Files
Files
connector.luau
-- Google Calendar API v3. Arguments and results keep Google's native field names. local API = "https://www.googleapis.com/calendar/v3" -- Request layer shared verbatim by the Google connectors (tools/validate checks they match). type Options = {[string]: any} type Endpoint = {method: string, path: string, access: string?, query: {string}?, body: boolean?, defaults: Options?, list: string?, required: {[string]: string}?, help: string} local function text(value: any, field: string): string assert(type(value) == "string" and value ~= "", field .. " must be a nonempty string") return value end local function options(value: any): Options if value == nil then return {} end assert(type(value) == "table", "opts must be an object") for key in value do assert(type(key) == "string", "opts must have named fields") end return table.clone(value) end -- Moves the named fields from args into a query string; arrays repeat the key. local function query(args: Options, names: {string}): string local parts: {string} = {} for _, name in names do local value = args[name] args[name] = nil for key, item in (if type(value) == "table" then value else {value}) do assert(type(key) == "number" and (type(item) == "string" or type(item) == "number" or type(item) == "boolean"), name .. " must be a string, number, boolean or an array of them") table.insert(parts, url.encode(name) .. "=" .. url.encode(item)) end end return if #parts > 0 then "?" .. table.concat(parts, "&") else "" end -- Older APIs name the reason in errors[], newer ones in an ErrorInfo detail. local function reasonOf(problem: any): string? for _, list in {problem.errors, problem.details} :: {any} do if type(list) == "table" then for _, item in list do if type(item) == "table" and type(item.reason) == "string" then return item.reason end end end end return nil end local function fail(operation: string, response: HttpResponse): never local ok, decoded = pcall(json.decode, await(response.body:readPrefix(4096))) local problem = if ok and type(decoded) == "table" and type(decoded.error) == "table" then decoded.error else {} local reason = reasonOf(problem) local message = "Google HTTP " .. tostring(response.statusCode) if type(problem.status) == "string" then message ..= " (" .. problem.status .. ")" end if type(problem.message) == "string" then message ..= ": " .. string.sub(problem.message, 1, 600) end if reason then message ..= " [" .. reason .. "]" end local retry = response.headers["retry-after"] if retry and retry[1] then message ..= "; Retry-After: " .. retry[1] end local limited = reason ~= nil and string.find(string.lower(reason), "ratelimitexceeded", 1, true) ~= nil return houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode, retryable = response.statusCode == 429 or response.statusCode >= 500 or limited, message = message}) end local function decode(operation: string, response: HttpResponse): any if response.statusCode < 200 or response.statusCode >= 300 then fail(operation, response) end local raw = await(response.body:readAll()) if raw == "" then return {success = true} end local ok, value = pcall(json.decode, raw) if not ok or type(value) ~= "table" or not string.match(raw, "^%s*{") then houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode, retryable = false, message = "Google returned an invalid JSON object"}) end return value end local function call(operation: string, method: string, href: string, body: any?): any return decode(operation, await(http.request({method = method, url = href, headers = if body ~= nil then {["Content-Type"] = {"application/json"}} else nil, body = if body ~= nil then json.encode(body) else nil}))) end -- Accepts a docs.google.com editor URL in place of its file ID; published and responder links (/d/e/...) carry no ID. local function docsId(value: any, product: string, field: string): any if type(value) ~= "string" then return value end local rest = string.match(value, "^https://docs%.google%.com/" .. product .. "/d/(.*)$") or string.match(value, "^https://docs%.google%.com/" .. product .. "/u/%d+/d/(.*)$") or string.match(value, "^https://docs%.google%.com/a/[^/]+/" .. product .. "/d/(.*)$") local id: string = if rest then string.match(rest, "^[^/?#]*") or "" else value assert(string.match(id, "^[%w_%-]+$") and id ~= "e", field .. " must be an ID or its https://docs.google.com/" .. product .. "/d/<id> URL") return id end -- Moves {placeholders} and declared query fields from args into the URL; remaining fields form the JSON body. local function target(name: string, endpoint: Endpoint, args: Options): string local defaults: Options = endpoint.defaults or {} for key, value in defaults do if args[key] == nil then args[key] = value end end local required: {[string]: string} = endpoint.required or {} for field, kind in required do local value = args[field] assert(if kind == "array" then type(value) == "table" and value[1] ~= nil elseif kind == "string" then type(value) == "string" and value ~= "" elseif kind == "object" then type(value) == "table" and next(value) ~= nil and value[1] == nil else false, name .. " requires " .. field .. " as a nonempty " .. kind) end local path = string.gsub(endpoint.path, "{(%w+)}", function(field: string) local value = url.segment(text(args[field], field), field) args[field] = nil return value end) path ..= query(args, endpoint.query or {}) if not endpoint.body then assert(next(args) == nil, name .. " received an unknown option") end return API .. path end local function invoke(name: string, endpoint: Endpoint, input: any): any local args = options(input) local result = call(name, endpoint.method, target(name, endpoint, args), if endpoint.body then args else nil) if endpoint.list and result[endpoint.list] == nil then result[endpoint.list] = json.decode("[]") end return result end local exports: {[string]: any} = {} local help: {[string]: string} = {} -- Exposes an operation when the connection allows the access it needs, if any. local function export(name: string, access: string?, fn: (any) -> any, doc: string) if access == nil or houston.allows(access) then exports[name], help[name] = fn, doc end end local function exportEndpoints(endpoints: {[string]: Endpoint}) for name, endpoint in endpoints do export(name, endpoint.access, function(args: Options?): any return invoke(name, endpoint, args) end, endpoint.help) end end -- help() introduces the API, then documents exactly the configured operations. local function helpWith(overview: {string}): () -> string return function(): string local names: {string} = {} for name in help do table.insert(names, name) end table.sort(names) local lines = table.clone(overview) for _, name in names do table.insert(lines, help[name]) end return table.concat(lines, "\n") end end -- End of the shared request layer. local PRIMARY = {calendarId = "primary"} local WRITE = {"sendUpdates", "conferenceDataVersion", "supportsAttachments", "maxAttendees"} local endpoints: {[string]: Endpoint} = { listCalendars = {method = "GET", path = "/users/me/calendarList", list = "items", query = {"maxResults", "pageToken", "minAccessRole", "showDeleted", "showHidden", "showOwnOrganizationOnly", "syncToken"}, help = "listCalendars({maxResults?, pageToken?, minAccessRole?, showHidden?, ...}?) -> {items=[{id, summary, accessRole, primary?, timeZone, backgroundColor, ...}], nextPageToken?, nextSyncToken?}. Calendars in the user's list, including subscribed ones. maxResults ≤250; minAccessRole='writer' keeps calendars the user can add events to."}, getCalendar = {method = "GET", path = "/calendars/{calendarId}", defaults = PRIMARY, help = "getCalendar({calendarId?}?) -> {id, summary, description?, timeZone, ...}. getCalendar().timeZone is the user's time zone."}, getColors = {method = "GET", path = "/colors", help = "getColors() -> {calendar={[colorId]={background, foreground}}, event={[colorId]={background, foreground}}}. The palettes behind calendar and event colorId values."}, listEvents = {method = "GET", path = "/calendars/{calendarId}/events", defaults = PRIMARY, list = "items", query = {"timeMin", "timeMax", "q", "maxResults", "pageToken", "singleEvents", "orderBy", "timeZone", "showDeleted", "updatedMin", "syncToken", "iCalUID", "eventTypes", "privateExtendedProperty", "sharedExtendedProperty", "maxAttendees", "showHiddenInvitations"}, help = "listEvents({calendarId?, timeMin?, timeMax?, q?, singleEvents?, orderBy?, maxResults?, pageToken?, eventTypes?, syncToken?, ...}?) -> {items=[event], nextPageToken?, nextSyncToken?, timeZone, ...}. Items already carry id, summary, start, end, attendees and status: don't getEvent each one. timeMin and timeMax are RFC 3339 with an offset (2026-10-12T09:00:00Z) and keep events that end after timeMin and start before timeMax. singleEvents=true expands recurring events into instances and allows orderBy='startTime'. q searches text fields. maxResults ≤2500 (default 250); a page may hold fewer events while more remain. The last page has nextSyncToken: listEvents({syncToken}) later returns only changes, cancelled events included, and accepts none of timeMin, timeMax, q, orderBy, iCalUID, updatedMin or the extended-property filters; HTTP 410 [fullSyncRequired] or [updatedMinTooLongAgo] means list again without syncToken or updatedMin."}, getEvent = {method = "GET", path = "/calendars/{calendarId}/events/{eventId}", defaults = PRIMARY, query = {"timeZone", "maxAttendees"}, help = "getEvent({calendarId?, eventId, timeZone?, maxAttendees?}) -> event {id, status, summary, description?, location?, start, end, recurrence?, recurringEventId?, attendees?, organizer, conferenceData?, htmlLink, ...}."}, listEventInstances = {method = "GET", path = "/calendars/{calendarId}/events/{eventId}/instances", defaults = PRIMARY, list = "items", query = {"timeMin", "timeMax", "maxResults", "pageToken", "timeZone", "showDeleted", "originalStart", "maxAttendees"}, help = "listEventInstances({calendarId?, eventId, timeMin?, timeMax?, maxResults?, pageToken?, originalStart?}) -> {items, nextPageToken?}. Occurrences of a recurring event; each has its own id and recurringEventId."}, queryFreeBusy = {method = "POST", path = "/freeBusy", body = true, required = {timeMin = "string", timeMax = "string", items = "array"}, help = "queryFreeBusy({timeMin, timeMax, items={{id='primary'}, {id='[email protected]'}}, timeZone?}) -> {calendars={[id]={busy={{start=..., ['end']=...}}, errors?}}}. Busy intervals only, without event details; works for colleagues whose calendars share free/busy. Up to 50 calendars per call; a calendar it cannot read reports errors with an empty busy list, so check errors before treating anyone as free."}, insertEvent = {method = "POST", path = "/calendars/{calendarId}/events", access = "data:write", body = true, defaults = PRIMARY, query = WRITE, help = "insertEvent({calendarId?, summary, start={dateTime='2026-10-13T09:00:00+02:00', timeZone?} or {date='2026-10-13'}, ['end']={...}, attendees?={{email=...}}, description?, location?, recurrence?={'RRULE:FREQ=WEEKLY;COUNT=4'}, reminders?, colorId?, id?, sendUpdates?, conferenceDataVersion?}) -> event. All-day events end on the following date (end is exclusive). With recurrence, start.timeZone and ['end'].timeZone are required (an IANA name such as 'Europe/Paris'). sendUpdates: all, externalOnly or none (default none: attendees get no email). For Google Meet, pass conferenceDataVersion=1 and conferenceData={createRequest={requestId='<unique>', conferenceSolutionKey={type='hangoutsMeet'}}}. A caller-chosen id (5 to 1024 characters of lowercase a-v and digits) makes a repeated insert usually fail with HTTP 409 [duplicate] instead of creating a second event."}, patchEvent = {method = "PATCH", path = "/calendars/{calendarId}/events/{eventId}", access = "data:write", body = true, defaults = PRIMARY, query = WRITE, help = "patchEvent({calendarId?, eventId, sendUpdates?, ...fields to change}) -> event. Only the given fields change; arrays such as attendees are replaced whole, so read the event and send the full list. Patching a recurring event's id changes the whole series; patch an instance id from listEventInstances to change one occurrence."}, deleteEvent = {method = "DELETE", path = "/calendars/{calendarId}/events/{eventId}", access = "data:write", defaults = PRIMARY, query = {"sendUpdates"}, help = "deleteEvent({calendarId?, eventId, sendUpdates?}) -> {success=true}. If the user organizes the event, attendees see it cancelled and sendUpdates='all' emails them; deleting an invitation only removes it from this calendar. Deleting a recurring event's id removes the whole series. HTTP 410 [deleted] means it was already deleted."}, moveEvent = {method = "POST", path = "/calendars/{calendarId}/events/{eventId}/move", access = "data:write", defaults = PRIMARY, query = {"destination", "sendUpdates"}, required = {destination = "string"}, help = "moveEvent({calendarId?, eventId, destination, sendUpdates?}) -> event. Moves the event to the destination calendar ID, which becomes its organizer. Only default events can move."}, quickAddEvent = {method = "POST", path = "/calendars/{calendarId}/events/quickAdd", access = "data:write", defaults = PRIMARY, query = {"text", "sendUpdates"}, required = {text = "string"}, help = "quickAddEvent({calendarId?, text, sendUpdates?}) -> event. Creates an event from text such as 'Lunch with Ana tomorrow 12pm'. Prefer insertEvent when the times are known."}, } exportEndpoints(endpoints) local overview = { "Google Calendar API v3. Every operation takes one named options object with Google's camelCase fields and returns Google's JSON unchanged; deletes return {success=true}. Calls return completed values: use instance.listEvents(...) directly, without await.", "calendarId defaults to 'primary' (the connected account's calendar); other IDs, such as [email protected], come from listCalendars. Event times are {dateTime} in RFC 3339 with an offset or with timeZone, or {date='2026-10-13'} for all-day events. Luau reserves end: write event['end'] and {['end']=...}.", "Lists return one page: pass nextPageToken as pageToken until it is absent. Empty lists are []. Example: listEvents({timeMin='2026-10-12T00:00:00Z', timeMax='2026-10-19T00:00:00Z', singleEvents=true, orderBy='startTime'}).", "No hidden paging or retries. Errors report the HTTP status, Google's message and reason, such as [notFound] for a missing event or a calendar the user cannot see. Google allows about 600 requests per minute per user; HTTP 429 and 403 [rateLimitExceeded] or [userRateLimitExceeded] are retryable after a pause.", } if houston.allows("data:write") then table.insert(overview, "Writes can change only events, not calendars or their sharing. Events on calendars the user can only read fail with HTTP 403. A failed or timed-out write may already have succeeded: check with getEvent or listEvents before repeating it, or give insertEvent an id and check it with getEvent({eventId=id}).") end exports.help = helpWith(overview) return exportshouston.json
{ "schema_version": 2, "name": "Google Calendar", "files": [ "connector.luau" ], "icon": "icon.svg", "access": [ { "name": "data", "label": "Access", "levels": [ { "value": "read", "label": "Read" }, { "value": "write", "label": "Write" } ], "default": "read" } ], "auth": { "oauth": { "type": "oauth2", "label": "Connect with Google", "brand": "google", "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth", "token_url": "https://oauth2.googleapis.com/token", "client_id": "{{publisher.client_id}}", "client_secret": "{{publisher.client_secret}}", "client_auth": "body", "pkce": "S256", "require_refresh": true, "authorize_params": { "access_type": "offline", "include_granted_scopes": "false", "prompt": "consent" }, "scopes": [ { "values": [ "https://www.googleapis.com/auth/userinfo.email" ] }, { "if": "{{ is access.data \"read\" }}", "values": [ "https://www.googleapis.com/auth/calendar.readonly" ] }, { "if": "{{ is access.data \"write\" }}", "values": [ "https://www.googleapis.com/auth/calendar.readonly", "https://www.googleapis.com/auth/calendar.events" ] } ], "account": { "method": "GET", "url": "https://www.googleapis.com/oauth2/v2/userinfo", "headers": { "Authorization": { "value": "Bearer {{auth.oauth.access_token}}" } }, "label": "/email" } } }, "publisher": { "client_id": { "type": "string", "label": "Google OAuth client ID", "required": true, "order": 1 }, "client_secret": { "type": "secret", "label": "Google OAuth client secret", "required": true, "order": 2 } }, "proxy": [ { "match": { "protocol": "http", "host": [ "www.googleapis.com" ], "method": [ "GET" ], "path": [ "/calendar/v3/users/me/calendarList", "/calendar/v3/colors", "/calendar/v3/calendars/{calendarId}", "/calendar/v3/calendars/{calendarId}/events", "/calendar/v3/calendars/{calendarId}/events/{eventId}", "/calendar/v3/calendars/{calendarId}/events/{eventId}/instances" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } }, { "match": { "protocol": "http", "host": [ "www.googleapis.com" ], "method": [ "POST" ], "path": [ "/calendar/v3/freeBusy" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } }, { "if": "{{ allows access.data \"write\" }}", "match": { "protocol": "http", "host": [ "www.googleapis.com" ], "method": [ "POST" ], "path": [ "/calendar/v3/calendars/{calendarId}/events", "/calendar/v3/calendars/{calendarId}/events/quickAdd", "/calendar/v3/calendars/{calendarId}/events/{eventId}/move" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } }, { "if": "{{ allows access.data \"write\" }}", "match": { "protocol": "http", "host": [ "www.googleapis.com" ], "method": [ "PATCH", "DELETE" ], "path": [ "/calendar/v3/calendars/{calendarId}/events/{eventId}" ] }, "action": { "headers": { "set": { "Authorization": "Bearer {{auth.oauth.access_token}}" } } } } ] }icon.svg
README.md
--- description: Check schedules and availability, and plan events in Google Calendar. --- # Google Calendar Let agents see what is on your calendar and help plan your time. - Review upcoming events across your calendars, including recurring ones. - Find free time with busy/free availability. - With **Write** access: create, update, move and cancel events, invite attendees and add Google Meet links. Read access cannot change your calendars or notify attendees.SETUP.md
# Connect your Google account 1. Choose the level for **Access**: - **Read** to let agents read without changing anything. - **Write** to also let agents create, change and cancel events. 2. Select **Continue with Google**, choose your account, and approve the permissions Google lists. If Google shows a checkbox per permission, tick them all: Houston refuses a partial grant. Each Google Calendar connection asks only for its own permissions, so connecting Google Calendar does not grant access to your other Google services. ## Advanced: changing access and troubleshooting - To change the access level, edit the connection and connect with Google again. Google then asks for the new set of permissions. - To revoke access, remove the connection in Houston, or remove Houston from [your Google Account's third-party connections](https://myaccount.google.com/connections). - Google Workspace administrators can block third-party apps. If Google refuses the connection, ask your administrator to allow Houston.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = {}, config = {}, endpoint = { "GET", "https://www.googleapis.com/calendar/v3/users/me/calendarList" }, expected = "Bearer synthetic-oauth-token", header = "Authorization", method = "oauth", oauth = true, publisher = { client_id = "synthetic-public-client", client_secret = "synthetic-client-secret", }, scopes = true, }, }) end, }endpoints.luau
return { contract = function(m) m.endpointRules() end, }errors.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "write"}, configure = function() calls, status, payload, responseHeaders = 0, 200, "{}", {} http = {request = function(req) calls += 1 return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)}) end} end, run = function(c) local function upstream(code, body, headers, expected) status, payload, responseHeaders = code, body, headers local before = calls local ok, err = pcall(c.insertEvent, {summary = "Planning", start = {date = "2026-10-21"}, ["end"] = {date = "2026-10-22"}}) for _, text in expected do assert(not ok and string.find(tostring(err), text, 1, true), "missing " .. text .. " in " .. tostring(err)) end assert(string.find(tostring(err), '"operation":"insertEvent"', 1, true), tostring(err)) assert(calls == before + 1, "failed write was retried") end upstream(403, '{"error":{"code":403,"message":"Rate Limit Exceeded","errors":[{"domain":"usageLimits","reason":"rateLimitExceeded"}]}}', {}, {"Google HTTP 403: Rate Limit Exceeded [rateLimitExceeded]", '"retryable":true'}) upstream(403, '{"error":{"code":403,"message":"User Rate Limit Exceeded","errors":[{"domain":"usageLimits","reason":"userRateLimitExceeded"}]}}', {["retry-after"] = {"7"}}, {"[userRateLimitExceeded]", "Retry-After: 7", '"retryable":true'}) upstream(403, '{"error":{"code":403,"message":"Request had insufficient authentication scopes.","status":"PERMISSION_DENIED","errors":[{"reason":"insufficientPermissions"}]}}', {}, {"HTTP 403 (PERMISSION_DENIED): Request had insufficient authentication scopes. [insufficientPermissions]", '"retryable":false'}) upstream(409, '{"error":{"code":409,"message":"The requested identifier already exists.","errors":[{"reason":"duplicate"}]}}', {}, {"HTTP 409", "[duplicate]", '"retryable":false'}) upstream(429, '{"error":{"code":429,"message":"Too many requests","status":"RESOURCE_EXHAUSTED"}}', {["retry-after"] = {"30"}}, {"HTTP 429 (RESOURCE_EXHAUSTED)", "Retry-After: 30", '"retryable":true'}) upstream(401, "not json", {}, {"Google HTTP 401", '"retryable":false'}) upstream(400, "<html><title>Error 400 (Bad Request)</title></html>", {}, {"Google HTTP 400", '"retryable":false'}) upstream(503, '{"error":{"code":503,"message":"Backend Error","errors":[{"reason":"backendError"}]}}', {}, {"HTTP 503", '"retryable":true'}) upstream(200, "<html>Maintenance</html>", {}, {"invalid JSON object"}) upstream(200, "[]", {}, {"invalid JSON object"}) upstream(200, "null", {}, {"invalid JSON object"}) status, payload = 410, '{"error":{"code":410,"message":"Sync token is no longer valid, a full sync is required.","errors":[{"reason":"fullSyncRequired"}]}}' local ok, err = pcall(c.listEvents, {syncToken = "old"}) assert(not ok and string.find(tostring(err), "[fullSyncRequired]", 1, true) and string.find(tostring(err), '"retryable":false', 1, true), tostring(err)) status, payload = 404, '{"error":{"code":404,"message":"Not Found","errors":[{"reason":"notFound"}]}}' ok, err = pcall(c.getEvent, {eventId = "missing"}) assert(not ok and string.find(tostring(err), "HTTP 404: Not Found [notFound]", 1, true) and string.find(tostring(err), '"operation":"getEvent"', 1, true), tostring(err)) end, }manifest.luau
return { contract = function(m) local function google(access, scopes) local r, err = m.resolve( { client_id = "publisher-client", client_secret = "publisher-secret" }, {}, nil, "oauth", { data = access } ) assert(r and not err, tostring(err)) local want = { "https://www.googleapis.com/auth/userinfo.email" } for _, scope in scopes do table.insert(want, "https://www.googleapis.com/auth/" .. scope) end assert(m.equal(r.Scopes, want), "requested OAuth scopes") r.Context.Auth.oauth.access_token = "fixture-token" return r end do local api = "https://www.googleapis.com/calendar/v3" local team = api .. "/calendars/team%40group.calendar.google.com" for _, access in { "read", "write" } do local scopes = { "calendar.readonly" } if access == "write" then scopes = m.concat(scopes, { "calendar.events" }) end local r = google(access, scopes) local reads = { "GET " .. api .. "/users/me/calendarList?maxResults=250", "GET " .. api .. "/colors", "GET " .. api .. "/calendars/primary", "GET " .. api .. "/calendars/en.usa%23holiday%40group.v.calendar.google.com/events?singleEvents=true", "GET " .. team .. "/events/e1", "GET " .. team .. "/events/e1/instances", "POST " .. api .. "/freeBusy", } m.routes(r, "Bearer fixture-token", true, reads) m.rejectOverrides(r, reads) local writes = { "POST " .. team .. "/events?sendUpdates=all", "POST " .. api .. "/calendars/primary/events/quickAdd?text=Lunch", "POST " .. team .. "/events/e1/move?destination=primary", "PATCH " .. team .. "/events/e1", "DELETE " .. team .. "/events/e1", } m.routes(r, "Bearer fixture-token", (access == "write"), writes) if access == "write" then m.rejectOverrides(r, writes) end m.routes(r, "Bearer fixture-token", false, { "POST https://oauth2.googleapis.com/token", "GET https://www.googleapis.com/drive/v3/files", "GET https://www.googleapis.com.evil.test/calendar/v3/calendars/primary", "GET https://calendar-json.googleapis.com/calendar/v3/calendars/primary", "GET https://content.googleapis.com/calendar/v3/calendars/primary", "POST https://www.googleapis.com/batch/calendar/v3", "GET " .. api .. "/calendars/primary/acl", "POST " .. api .. "/calendars/primary/acl", "POST " .. api .. "/calendars", "DELETE " .. api .. "/calendars/c1", "PUT " .. api .. "/calendars/primary", "PATCH " .. api .. "/calendars/primary", "POST " .. api .. "/calendars/primary/clear", "PUT " .. team .. "/events/e1", "POST " .. team .. "/events/import", "POST " .. team .. "/events/watch", "POST " .. api .. "/users/me/calendarList", "POST " .. api .. "/users/me/calendarList/watch", "DELETE " .. api .. "/users/me/calendarList/c1", "GET " .. api .. "/users/me/settings", "POST " .. api .. "/channels/stop", "GET " .. team .. "/events/%2e%2e/acl", "GET " .. api .. "/calendars/primary%2F..%2Facl/events", }) end end end, }reads.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "read"}, configure = function() requests, responses = {}, {} http = {request = function(req) table.insert(requests, req) assert(#responses > 0, "unexpected request: " .. req.url) return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader(table.remove(responses, 1))}) end} end, run = function(c) local API = "https://www.googleapis.com/calendar/v3" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "getCalendar,getColors,getEvent,listCalendars,listEventInstances,listEvents,queryFreeBusy", table.concat(names, ",")) local function sent(method, href) local req = requests[#requests] assert(req.method == method and req.url == href, req.method .. " " .. req.url) assert(req.headers == nil or req.headers.Authorization == nil, "connector set credentials") end responses = {'{"items":[{"id":"[email protected]","accessRole":"owner"}],"nextPageToken":"p+2"}', '{"kind":"calendar#calendarList"}'} local calendars = c.listCalendars({maxResults = 250, minAccessRole = "writer", pageToken = "p+1"}) assert(calendars.items[1].accessRole == "owner" and calendars.nextPageToken == "p+2") sent("GET", API .. "/users/me/calendarList?maxResults=250&pageToken=p%2B1&minAccessRole=writer") assert(requests[1].body == nil) assert(json.encode(c.listCalendars().items) == "[]", "absent lists must be empty arrays") sent("GET", API .. "/users/me/calendarList") responses = {'{"id":"[email protected]","timeZone":"Europe/Paris"}', '{"id":"en.usa#[email protected]"}'} assert(c.getCalendar().timeZone == "Europe/Paris") sent("GET", API .. "/calendars/primary") c.getCalendar({calendarId = "en.usa#[email protected]"}) sent("GET", API .. "/calendars/en.usa%23holiday%40group.v.calendar.google.com") responses = {'{"calendar":{"1":{"background":"#ac725e","foreground":"#1d1d1d"}},"event":{"11":{"background":"#dc2127","foreground":"#1d1d1d"}}}'} assert(c.getColors().event["11"].background == "#dc2127") sent("GET", API .. "/colors") assert(not pcall(c.getColors, {calendarId = "primary"}), "getColors takes no options") responses = {'{"items":[{"id":"e1"}],"nextPageToken":"next+1"}', '{"kind":"calendar#events","nextSyncToken":"s1"}'} local page = c.listEvents({timeMin = "2026-10-12T00:00:00Z", singleEvents = true, orderBy = "startTime", pageToken = "start+1", eventTypes = {"default", "focusTime"}}) assert(page.nextPageToken == "next+1" and page.items[1].id == "e1") sent("GET", API .. "/calendars/primary/events?timeMin=2026-10-12T00%3A00%3A00Z&pageToken=start%2B1&singleEvents=true&orderBy=startTime&eventTypes=default&eventTypes=focusTime") local empty = c.listEvents({calendarId = "[email protected]", q = "standup & review", maxResults = 2500}) assert(json.encode(empty.items) == "[]" and empty.nextSyncToken == "s1") sent("GET", API .. "/calendars/team%40group.calendar.google.com/events?q=standup%20%26%20review&maxResults=2500") responses = {'{"id":"e1_20261013T090000Z","recurringEventId":"e1"}', '{"items":[{"id":"e1_20261013T090000Z"}]}'} assert(c.getEvent({eventId = "e1_20261013T090000Z", timeZone = "Europe/Paris"}).recurringEventId == "e1") sent("GET", API .. "/calendars/primary/events/e1_20261013T090000Z?timeZone=Europe%2FParis") assert(#c.listEventInstances({calendarId = "[email protected]", eventId = "e1", timeMax = "2026-11-01T00:00:00+02:00"}).items == 1) sent("GET", API .. "/calendars/team%40group.calendar.google.com/events/e1/instances?timeMax=2026-11-01T00%3A00%3A00%2B02%3A00") responses = {'{"calendars":{"primary":{"busy":[{"start":"2026-10-13T09:00:00Z","end":"2026-10-13T10:00:00Z"}]}}}'} local busy = c.queryFreeBusy({timeMin = "2026-10-13T00:00:00Z", timeMax = "2026-10-14T00:00:00Z", items = {{id = "primary"}}}) assert(busy.calendars.primary.busy[1]["end"] == "2026-10-13T10:00:00Z") sent("POST", API .. "/freeBusy") assert(requests[#requests].headers["Content-Type"][1] == "application/json") assert(requests[#requests].body == '{"items":[{"id":"primary"}],"timeMax":"2026-10-14T00:00:00Z","timeMin":"2026-10-13T00:00:00Z"}', requests[#requests].body) local count = #requests for _, args in {{eventId = ""}, {eventId = 42}, {eventId = "e", unknown = true}, {"e"}, {eventId = ".."}, {eventId = "e/f"}, {eventId = "e%2Ff"}, {calendarId = "a\\b", eventId = "e"}, {eventId = "e\0"}, {calendarId = "", eventId = "e"}} do assert(not pcall(c.getEvent, args), "accepted " .. json.encode(args)) end assert(not pcall(c.getEvent, "e")) assert(not pcall(c.getEvent, {}), "getEvent requires eventId") assert(not pcall(c.listEvents, {eventTypes = {{}}})) assert(not pcall(c.listEvents, {key = "api-key"}), "unknown query options must fail") assert(not pcall(c.listCalendars, {fields = "items"})) assert(not pcall(c.listEvents, {q = {a = "b"}}), "query lists must be arrays") assert(not pcall(c.listEvents, {eventTypes = {"default", extra = "focusTime"}})) local day = {timeMin = "2026-10-13T00:00:00Z", timeMax = "2026-10-14T00:00:00Z"} for _, args in {{}, day, {timeMin = day.timeMin, timeMax = "", items = {{id = "primary"}}}, {timeMin = day.timeMin, timeMax = day.timeMax, items = {}}, {timeMin = day.timeMin, timeMax = day.timeMax, items = "primary"}, {timeMin = {day.timeMin}, timeMax = day.timeMax, items = {{id = "primary"}}}} do assert(not pcall(c.queryFreeBusy, args), "queryFreeBusy requires timeMin, timeMax and items: " .. json.encode(args)) end assert(#requests == count, "invalid input reached Google") assert(#responses == 0) end, }writes.luau
return { scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}}, access = {data = "write"}, configure = function() requests, responses = {}, {} http = {request = function(req) table.insert(requests, req) assert(#responses > 0, "unexpected request: " .. req.url) local response = table.remove(responses, 1) return fixture.operation({statusCode = response.status or 200, headers = {}, body = fixture.reader(response.body or "")}) end} end, run = function(c) local API = "https://www.googleapis.com/calendar/v3/calendars/" local names = {} for name in c do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "deleteEvent,getCalendar,getColors,getEvent,insertEvent,listCalendars,listEventInstances,listEvents,moveEvent,patchEvent,queryFreeBusy,quickAddEvent", table.concat(names, ",")) local function sent(method, href, body) local req = requests[#requests] assert(req.method == method and req.url == href, req.method .. " " .. req.url) assert(req.headers == nil or req.headers.Authorization == nil, "connector set credentials") if body then assert(req.headers["Content-Type"][1] == "application/json") assert(req.body == body, req.body) else assert(req.body == nil and req.headers == nil, "unexpected body") end end responses = {{body = '{"id":"new"}'}} local event = c.insertEvent({summary = "Planning", start = {dateTime = "2026-10-13T09:00:00Z"}, ["end"] = {dateTime = "2026-10-13T10:00:00Z"}, attendees = {{email = "[email protected]"}}, sendUpdates = "all", conferenceDataVersion = 1}) assert(event.id == "new") sent("POST", API .. "primary/events?sendUpdates=all&conferenceDataVersion=1", '{"attendees":[{"email":"[email protected]"}],"end":{"dateTime":"2026-10-13T10:00:00Z"},"start":{"dateTime":"2026-10-13T09:00:00Z"},"summary":"Planning"}') -- A caller-chosen id makes a repeated insert fail with 409 rather than duplicate the event. responses = {{body = '{"id":"planning20261013"}'}} c.insertEvent({calendarId = "[email protected]", id = "planning20261013", summary = "Planning", start = {date = "2026-10-13"}, ["end"] = {date = "2026-10-14"}}) sent("POST", API .. "team%40group.calendar.google.com/events", '{"end":{"date":"2026-10-14"},"id":"planning20261013","start":{"date":"2026-10-13"},"summary":"Planning"}') responses = {{body = '{"id":"new","summary":"Moved"}'}, {body = '{"id":"new"}'}, {body = '{"id":"q1"}'}, {status = 204}} assert(c.patchEvent({eventId = "new", summary = "Moved", sendUpdates = "none"}).summary == "Moved") sent("PATCH", API .. "primary/events/new?sendUpdates=none", '{"summary":"Moved"}') c.moveEvent({eventId = "new", destination = "[email protected]"}) sent("POST", API .. "primary/events/new/move?destination=team%40group.calendar.google.com") c.quickAddEvent({text = "Lunch with Ana tomorrow 12pm", sendUpdates = "all"}) sent("POST", API .. "primary/events/quickAdd?text=Lunch%20with%20Ana%20tomorrow%2012pm&sendUpdates=all") assert(c.deleteEvent({calendarId = "[email protected]", eventId = "new", sendUpdates = "all"}).success == true) sent("DELETE", API .. "team%40group.calendar.google.com/events/new?sendUpdates=all") local count = #requests assert(not pcall(c.patchEvent, {summary = "No ID"}), "patchEvent requires eventId") assert(not pcall(c.deleteEvent, {eventId = "e", summary = "x"}), "deleteEvent takes no body") assert(not pcall(c.moveEvent, {eventId = "e/../x", destination = "primary"})) assert(not pcall(c.quickAddEvent, {text = "Lunch", start = {}}), "quickAddEvent takes no body") assert(not pcall(c.insertEvent, {calendarId = "..", summary = "x"})) assert(not pcall(c.insertEvent, "Planning")) for _, args in {{eventId = "e"}, {eventId = "e", destination = ""}, {eventId = "e", destination = {}}} do assert(not pcall(c.moveEvent, args), "moveEvent requires destination") end assert(not pcall(c.quickAddEvent, {}), "quickAddEvent requires text") assert(not pcall(c.quickAddEvent, {text = ""})) assert(#requests == count, "invalid input reached Google") assert(#responses == 0) end, }