Fix login to Office 365 Accounts

This commit is contained in:
Janosch Maier 2022-04-11 22:20:15 +02:00 committed by Ben Gotow
parent 25e098f394
commit 9606f547fa
2 changed files with 16 additions and 1 deletions

View file

@ -32,7 +32,7 @@ const O365_SCOPES = [
'Calendars.ReadWrite', // calendar
'Calendars.ReadWrite.Shared', // calendar
// Future note: When you exchane the refresh token for an access token, you may
// Future note: When you exchange the refresh token for an access token, you may
// request these two OR the above set but NOT BOTH, because Microsoft has mapped
// two underlying systems with different tokens onto the single flow and you
// need to get an outlook token and not a Micrsosoft Graph token to use these APIs.

View file

@ -324,6 +324,21 @@ const start = () => {
app.removeListener('open-file', onOpenFileBeforeReady);
app.removeListener('open-url', onOpenUrlBeforeReady);
// Setting the Origin Header to 'localhost' when logging in on Office 365
// Otherwise O365 will produce a 400 error on the OAuth Login Process
const filter = {
urls: ["*://login.microsoftonline.com/*"]
};
session.defaultSession.webRequest.onBeforeSendHeaders(
filter,
(details, callback) => {
console.log(details);
details.requestHeaders['Origin'] = 'localhost';
callback({ requestHeaders: details.requestHeaders });
}
);
// Block remote JS execution in a second way in case our <meta> tag approach
// is compromised somehow https://www.electronjs.org/docs/tutorial/security
// This CSP string should match the one in app/static/index.html