diff --git a/.gitignore b/.gitignore index dd351a68f4e..01977f0907b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ yarn-error.log* # secrets calendar-service-account.json +calendar-service-account2.json # gatsby files .cache/ diff --git a/src/api/signup-submit.js b/src/api/signup-submit.js index 9fc1c9cfc15..a3c9896a37e 100644 --- a/src/api/signup-submit.js +++ b/src/api/signup-submit.js @@ -13,15 +13,20 @@ export default async function handler(req, res) { // Scopes required for the Google Calendar API const SCOPES = [ - 'https://www.googleapis.com/auth/calendar.events' + 'https://www.googleapis.com/auth/calendar' ]; // Create a JWT client using the service account key const auth = new google.auth.GoogleAuth({ keyFile: SERVICE_ACCOUNT_FILE, scopes: SCOPES, + clientOptions: { + subject: 'rob.moffat@finos.org', // Specify the user to impersonate + }, }); + //const client = auth.getClient() + // Create a Calendar API client const calendar = google.calendar({ version: 'v3', auth }); @@ -46,11 +51,11 @@ export default async function handler(req, res) { } - // const done = await calendar.events.patch({ - // calendarId: calendarId, - // eventId: eventId, - // resource: event2 - // }) + const done = await calendar.events.patch({ + calendarId: calendarId, + eventId: eventId, + resource: event2 + }) res.json(`ok bebob ${JSON.stringify("hello")}`) } \ No newline at end of file