Scheduling infrastructure for absolutely everyone.
If no expiry date then refresh the token (#7805)
Joe Au-Yeung13577a5dbef2
diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.tsindex a15da00f1d4..9be55dcb40d 100644--- a/packages/app-store/office365calendar/lib/CalendarService.ts+++ b/packages/app-store/office365calendar/lib/CalendarService.ts@@ -210,7 +210,13 @@ export default class Office365CalendarService implements Calendar {}private o365Auth = (credential: CredentialPayload) => {- const isExpired = (expiryDate: number) => expiryDate < Math.round(+new Date() / 1000);+ const isExpired = (expiryDate: number) => {+ if (!expiryDate) {+ return true;+ } else {+ return expiryDate < Math.round(+new Date() / 1000);+ }+ };const o365AuthCredentials = credential.key as O365AuthCredentials;const refreshAccessToken = async (refreshToken: string) => {@@ -240,7 +246,7 @@ export default class Office365CalendarService implements Calendar {return {getToken: () =>- !isExpired(o365AuthCredentials.expiry_date)+ !isExpired(o365AuthCredentials.expires_in)? Promise.resolve(o365AuthCredentials.access_token): refreshAccessToken(o365AuthCredentials.refresh_token),};diff --git a/packages/app-store/office365calendar/types/Office365Calendar.ts b/packages/app-store/office365calendar/types/Office365Calendar.tsindex d78f6a1ca09..814cc5def7f 100644--- a/packages/app-store/office365calendar/types/Office365Calendar.ts+++ b/packages/app-store/office365calendar/types/Office365Calendar.ts@@ -1,5 +1,5 @@export type O365AuthCredentials = {- expiry_date: number;access_token: string;refresh_token: string;+ expires_in: number;};