Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google & Microsoft calendar API integration #3340

Merged
merged 24 commits into from
Aug 15, 2018
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7f8a1e2
Refactor calendar-sync feature to be loaded on web.
damencho Jul 31, 2018
89ebc2f
Initial implementation of retrieving google calendar events.
damencho Aug 2, 2018
2e13d53
Initial implementation of retrieving microsoft calendar events.
damencho Aug 7, 2018
eacea85
Fixes comments.
damencho Aug 7, 2018
58362ea
Rework to use the promise part of microsoft-graph-client api.
damencho Aug 7, 2018
63a83df
Moves dispatching some actions, fixing comments.
damencho Aug 7, 2018
4e5b76a
Makes sure we do not initializeClient google-api client multiple times.
damencho Aug 7, 2018
ddf7fba
Do not try to login when fetching calendar entries.
damencho Aug 7, 2018
92f07c3
Updates profile display data on sign in.
damencho Aug 8, 2018
99e7af0
Propagate google-api state to calendar-sync only if we use google cal.
damencho Aug 8, 2018
aece063
Adds sign out action.
damencho Aug 8, 2018
ac1f410
Clears the event listener when the popup closes.
damencho Aug 8, 2018
f05cb30
Clears calendarIntegrationInstance on signOut.
damencho Aug 8, 2018
5b251a2
WIP: UI for calendar settings, refactor auth flows
damencho Aug 7, 2018
e554667
Clean up some unused constants, functions and exports.
damencho Aug 13, 2018
b00a5dd
break circular dependency of function and constant
virtuacoplenny Aug 13, 2018
340a4d5
Exports only isCalendarEnabled from functions.
damencho Aug 13, 2018
d132c4f
Checks isSignedIn when doing fetchCalendarEntries on web.
damencho Aug 13, 2018
2869186
address comments
virtuacoplenny Aug 14, 2018
7ade6d0
Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
damencho Aug 14, 2018
940b42e
Fixes storing token expire time and refreshing tokens in Microsoft impl.
damencho Aug 14, 2018
d103f40
Address comments
virtuacoplenny Aug 14, 2018
4ca5eff
update jsdocs, get google app id from redux
virtuacoplenny Aug 15, 2018
3ec0b88
clear integration instead of actual sign out
virtuacoplenny Aug 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes storing token expire time and refreshing tokens in Microsoft impl.
  • Loading branch information
damencho committed Aug 14, 2018
commit 940b42e977ee3e0c2e112c27702fa8fa95d125f7
25 changes: 9 additions & 16 deletions react/features/calendar-sync/web/microsoftCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const MS_API_CONFIGURATION = {
*
* @type {string}
*/
MS_CONSUMER_TENANT: '9188040d-6c67-4c5b-b112-36a304b66da',
MS_CONSUMER_TENANT: '9188040d-6c67-4c5b-b112-36a304b66dad',

/**
* The redirect URL to be used by the Microsoft API on successful
Expand Down Expand Up @@ -202,7 +202,7 @@ export const microsoftCalendarApi = {
authState: undefined,
accessToken: tokenParts.accessToken,
idToken: tokenParts.idToken,
tokenExpires: tokenParts.tokenExpires,
tokenExpires: params.tokenExpires,
userDomainType: tokenParts.userDomainType,
userSigninName: tokenParts.userSigninName
}));
Expand Down Expand Up @@ -259,21 +259,15 @@ export const microsoftCalendarApi = {
= getState()['features/calendar-sync'].msAuthState || {};
const tokenExpires = parseInt(state.tokenExpires, 10);
const isExpired = now > tokenExpires && !isNaN(tokenExpires);
const validToken = state.accessToken && !isExpired;

if (!validToken) {
return Promise.resolve(false);
if (state.accessToken && isExpired) {
// token expired, let's refresh it
return dispatch(this._refreshAuthToken())
.then(() => true)
.catch(() => false);
}

const client = Client.init({
authProvider: done => done(null, state.accessToken)
});

return client
.api('/me')
.get()
.then(() => true)
.catch(() => false);
return Promise.resolve(state.accessToken && !isExpired);
};
},

Expand Down Expand Up @@ -324,7 +318,7 @@ export const microsoftCalendarApi = {
dispatch(setCalendarAPIAuthState({
accessToken: params.access_token,
idToken: params.id_token,
tokenExpires: parseInt(params.tokenExpires, 10)
tokenExpires: params.tokenExpires
}));
});
};
Expand Down Expand Up @@ -496,7 +490,6 @@ function getValidatedTokenParts(tokenInfo, guids, appId) {
return {
accessToken: tokenInfo.access_token,
idToken,
tokenExpires: expires.getTime(),
userDisplayName: payload.name,
userDomainType:
payload.tid === MS_API_CONFIGURATION.MS_CONSUMER_TENANT
Expand Down