diff --git a/packages/codemode-plugins/googleCalendar/src/index.ts b/packages/codemode-plugins/googleCalendar/src/index.ts index 33076caf..7950d2ad 100644 --- a/packages/codemode-plugins/googleCalendar/src/index.ts +++ b/packages/codemode-plugins/googleCalendar/src/index.ts @@ -318,6 +318,13 @@ function applyEventFields( // ─── Plugin ────────────────────────────────────────────────────── const SCOPES = ["https://www.googleapis.com/auth/calendar"]; +// Meet settings are separate from Calendar access. Include them in user consent +// so Calendar extensions can configure recording on Calendar-created meetings. +// Keep Calendar request/service-account scopes unchanged. +const CONSENT_SCOPES = [ + ...SCOPES, + "https://www.googleapis.com/auth/meetings.space.settings", +]; const optionalPositiveInteger = t.Optional(PositiveInteger); const calendarId = NonEmptyString; @@ -615,7 +622,7 @@ export default function googleCalendar(rl: CodemodePluginAPI) { rl.setVersion("0.1.0"); rl.setCredential(googleCredential("googleCalendar", SCOPES)); - rl.setOAuth(googleOAuth("googleCalendar", SCOPES, "GOOGLE_CALENDAR")); + rl.setOAuth(googleOAuth("googleCalendar", CONSENT_SCOPES, "GOOGLE_CALENDAR")); rl.setConnectionSchema(t.Object(googleConnection("GOOGLE_CALENDAR"))); diff --git a/packages/codemode/src/tests/credential-declaration.test.ts b/packages/codemode/src/tests/credential-declaration.test.ts index 90ec2446..ac5eeda8 100644 --- a/packages/codemode/src/tests/credential-declaration.test.ts +++ b/packages/codemode/src/tests/credential-declaration.test.ts @@ -97,7 +97,7 @@ describe("registry-backed plugins declare their credential", () => { }); } - it("Google and Microsoft sign for exactly the scopes their consent asks for", () => { + it("Google and Microsoft sign for their required scopes, with Calendar-only service accounts preserved", () => { const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048, privateKeyEncoding: { type: "pkcs8", format: "pem" }, @@ -126,7 +126,11 @@ describe("registry-backed plugins declare their credential", () => { assert.equal(auth?.kind, "oauth2"); assert.deepEqual( auth?.kind === "oauth2" ? auth.scopes : undefined, - def.oauth?.scopes, + // Calendar user consent additionally authorizes Meet extensions. Existing + // service-account Calendar calls must not require new admin delegation. + def.name === "googleCalendar" + ? ["https://www.googleapis.com/auth/calendar"] + : def.oauth?.scopes, def.name, ); assert.equal(selection?.jwtIdentity?.issuer, "robot@example.com"); diff --git a/packages/codemode/src/tests/google-calendar-meet-consent.test.ts b/packages/codemode/src/tests/google-calendar-meet-consent.test.ts new file mode 100644 index 00000000..231a9b68 --- /dev/null +++ b/packages/codemode/src/tests/google-calendar-meet-consent.test.ts @@ -0,0 +1,16 @@ +import assert from "node:assert/strict"; +import { it } from "node:test"; +import googleCalendar from "../../../codemode-plugins/googleCalendar/src/index.js"; +import { createPluginAPI } from "../plugin/api.js"; + +it("Calendar consent includes Meet settings without dropping Calendar access", () => { + const { api, resolve } = createPluginAPI("googleCalendar"); + googleCalendar(api); + const plugin = resolve(); + assert.deepEqual(plugin.oauth?.scopes, [ + "https://www.googleapis.com/auth/calendar", + "https://www.googleapis.com/auth/meetings.space.settings", + ]); + assert.equal(plugin.oauth?.grant, "google"); + assert.ok(plugin.actions.some((action) => action.name === "event.create")); +});