Fetch Calendars
This API endpoint is triggered by the extension interface to display all Google calendars found in the users provisioned account in a list when selecting a calendar to attach with a Scrims calendar.
Endpoint
GET /google/calendars HTTP/1.1
Host: api.atomcal.com/api/v2
Content-Type: application/x-www-form-urlencoded
Triggered by: Extension interface
Authentication: security.verifyAuthToken
This also reads the calendar from Google API and synchronize the locally saved calendar list before returning the updated list of calendars.
Example Responses
200 (successful operation)
res.status(200).send({ calendars });
400 (bad response)
Boom.badRequest(errorMessage)
Implementation details
Fetch Google Calendars For Member
Using the member id obtained from the token authenticator service select the Account and obtain Google authentication token to then fetch Google calendars using Google calendar API for this user accounts.
let calendarListUri = `https://www.googleapis.com/calendar/v3/users/me/calendarList?key=${googleAPIKey}`;
let gotCalendarList = await got.get(calendarListUri, {
headers: {
Authorization,
"Content-Type": "application/json",
},
});
Once latest Google calendars list is fetched, update the locally saved Google calendars by either adding non existing (new) calendar or delete those which doesn't exist in the fetched list.
Register notification channels
Register notification channels for Google calendar and Scrims calendar.
Return all Google calendars
Finally read all the google calendars using the member id obtained from the token authenticator service and return all saved Google calendars.
Edge cases
In case Google account authentication code is expired or refresh token is malformed it throws a bad request error.