Why does Nylas require full Google Calendar scope when using primary keyword?

Hi team,
We are trying to fetch Google Calendar events through Nylas using the primary keyword as described in the docs (https://developer.nylas.com/docs/dev-guide/scopes/).

Google allows accessing events from the primary calendar using only:

https://www.googleapis.com/auth/calendar.events.readonly

But Nylas requires the broader:

https://www.googleapis.com/auth/calendar

in order to use the primary keyword.

Question:
Why does Nylas require the full calendar scope specifically when using the primary keyword, even though Google’s own API allows primary calendar event access with the calendar.events.readonly scope?

Hello, Faizan!

the primary query parameter requires the reading of calendar attributes, and that requires the specific https://www.googleapis.com/auth/calendar scope. SInce all you’re doing with https://www.googleapis.com/auth/calendar.events.readonly is reading events (objects) from the calendar, these are actually two distinct operations.

I hope that helped!

Thank you,–Sam Xavier,
Support Engineer, Nylas

@Samuelpx
Thanks for the quick response!!

Currently we are using google’s native calendar APIs to read the calendar events and it’s working fine when the primary calendarId is used to fetch the events with the only the https://www.googleapis.com/auth/calendar.events.readonly scope.

However, when we try to do the same with Nylas we need to have broader scope. Here are the code snippets for better clarity

When Using Nylas:
return this.nylasClient.events.list({
identifier: grantId,
queryParams: {
calendarId: 'primary',
start: startTime.toString(),
end: endTime.toString(),
limit,
...(pageToken && { pageToken }),
},
});

When using Google API:

const googleEventParams = {
calendarId: 'primary',
timeMax: endTime,
timeMin: startTime,
timeZone: 'UTC',
maxResults: 2500,
orderBy: 'startTime',
singleEvents: true,
};
//the above googleEventParams is used to fetch calendar events using google's calendar api

Hello,

When you use calendarId: 'primary' with Nylas, Nylas makes an additional API call to resolve “primary” to the actual calendar ID before fetching events. This resolution call hits a different Google API endpoint that requires broader scopes.

Many thanks,
Samuel R.
Support Engineer, Nylas