I have tried implementing MSAL into a webapp I'm developing, but I've run into some issues, especially with IE and Edge.
The first issue arrises in both chrome and IE/Edge. Upon login I get 2 popups. Before the second popup concludes, the program have already called the Graph API and returned data, so why it shows, I do not know. The code is as follows:
function login(){
clientApplication = clientApplication || new Msal.UserAgentApplication({ClientId}, null, function (errorDes, token, error, tokenType) {});
clientApplication.loginPopup(["user.read files.readwrite.all group.readwrite.all"]).then(function (token) {
getAccessToken();
}, function (error) {
// handle error
});
}
function getAccessToken() {
clientApplication.acquireTokenSilent(["user.read files.readwrite.all group.readwrite.all"]).then(function (token) {
//Call Graph API and do stuff.
});
}
Apart from showing 2 popups, this works perfectly in chrome. If I leave out any of this, I will not be authenticated.
Now, the second part is a but more problematic. I have included the polyfill for promises to make it work in IE, but I still encounter something wierd. If I do not disable Protected Mode in IE, both popups open, but the first one redirects to https://{site}.azurewebsites.net/null . The second popup redirects to about:blank. Neither windows closes, as would be expected.
However, if I do disable Protected Mode, as suggested in the MSAL.js documentation for internal testing, I do get authenticated - the popups just doesn't close automatically. This is obviously not a viable solution for a multi-tenant webapp..
Is there something really wrong about my authentication flow, or am I just missing something? Is there any decent documentation of running authentication with MSAL.js in a single page applicaiton?
EDIT: After some digging, I've found that the authflow is also started in the iframe that is used to make the silent calls. Is there any reason the entire page is also loaded in said iframe? It run all my functions that is run when the dom is ready..
It appears as if no calls are silent, but always requires a popup..