We are using NylasSchedulerEditor component from nylas/react, in the following way :
<NylasSchedulerEditor
nylasApiRequest={nylasApiRequest}
defaultSchedulerConfigState={defaultSchedulerConfigState}
requiresSlug
schedulerPreviewLink={${window.location.origin}/schedules/{config.id}/{slug}
}
/>
For nylasApiRequest we have overided all four methods something like this
-
Request method we are doing something like this
async request(args) {
try {const response = await fetch(
NYLAS_BASE_URL/v3/grants/me/calendars
,
{
method: GET,
body: JSON.stringify(args.body),
headers: {
…args.headers,
Authorization:Bearer ${this.accessToken}
,
‘Content-Type’: ‘application/json’,
},
},
);if (!response.ok) {
return { error:Error: ${response.status} ${response.statusText}
};
}
const data = await response.json();
return [data, null];
} catch (error) {
return { error: ‘Error’ };
}
} -
currentUser
async currentUser() {
const response = await fetch(‘NYLAS_BASE_URL/v3/grants/me’, {
method: ‘GET’,
headers: {
Authorization:Bearer ${this.accessToken}
,
‘Content-Type’: ‘application/json’,
},
});if (!response.ok) {
return { error:Error: ${response.status} ${response.statusText}
};
}
const responseData = await response.json();
return responseData.data;
} -
setDeafultAuthArgs
async setDefaultAuthArgs(authArgs: never) {
return authArgs;
} -
authenthicationUrl
async authenticationUrl() {
return${window.location.origin}/login
;
}
When we submit the SchedulerEditor, it makes a POST request to NYLAS_BASE_URL/v3/grants/me/scheduling/configurations which by default picks up wrong calendar in it’s body because calendar_id in case of outlook calendar is something like ‘AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AooplM-I8wkmVHh-1SFxiLAAAAAAUlQAA’ and we run into error like
“error”: {
“type”: “invalid_request_error”,
“message”: “Calendar username@outlook.com does not belong to username@outlook.com”
}
Note: This only happens for microsoft calendar, as calendarId is aplhanumeric