From 6a9632bb124cd092534104b82a4a369702410cee Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 22 Apr 2021 13:27:03 +0000 Subject: [PATCH] Added User.Read explicitly to office 365 oauth scopes, as it seems some setups do not automatically apply this scope. --- lib/calendarClient.ts | 4 ++-- pages/api/integrations/office365calendar/add.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/calendarClient.ts b/lib/calendarClient.ts index bfea4bf66c..f224383b47 100644 --- a/lib/calendarClient.ts +++ b/lib/calendarClient.ts @@ -24,7 +24,7 @@ const o365Auth = (credential) => { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ - 'scope': 'Calendars.Read Calendars.ReadWrite', + 'scope': 'User.Read Calendars.Read Calendars.ReadWrite', 'client_id': process.env.MS_GRAPH_CLIENT_ID, 'refresh_token': refreshToken, 'grant_type': 'refresh_token', @@ -200,4 +200,4 @@ const getBusyTimes = (withCredentials, dateFrom, dateTo) => Promise.all( const createEvent = (credential, evt: CalendarEvent) => calendars([ credential ])[0].createEvent(evt); -export { getBusyTimes, createEvent, CalendarEvent }; \ No newline at end of file +export { getBusyTimes, createEvent, CalendarEvent }; diff --git a/pages/api/integrations/office365calendar/add.ts b/pages/api/integrations/office365calendar/add.ts index e5c05cb922..7a390dcad2 100644 --- a/pages/api/integrations/office365calendar/add.ts +++ b/pages/api/integrations/office365calendar/add.ts @@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { getSession } from 'next-auth/client'; import prisma from '../../../../lib/prisma'; -const scopes = ['Calendars.Read', 'Calendars.ReadWrite']; +const scopes = ['User.Read', 'Calendars.Read', 'Calendars.ReadWrite']; export default async function handler(req: NextApiRequest, res: NextApiResponse) { if (req.method === 'GET') {