I am trying to figure how to progamatically close the MSAL browser pop up in it's 2.0 version. https://github.com/AzureAD/microsoft-authentication-library-for-js
Currently i trigger this popup through a click in a web page.
The window.close does not close the popup, is there an alternative way to achieve this ?
function msalAuth(){
const config = {
auth: {
clientId: 'xxx',
}
}
const loginRequest = {
scopes: ["User.ReadWrite"]
}
let accountId = "";
const myMsal = new msal.PublicClientApplication(config);
myMsal.loginPopup(loginRequest)
.then(function (loginResponse) {
accountId = loginResponse.account.homeAccountId;
// Display signed-in user content, call API, etc.
}).catch(function (error) {
//login failure
console.log(error);
});
const callbackId = myMsal.addEventCallback((message) => {
// This will be run every time an event is emitted after registering this callback
if (message.eventType === msal.EventType.LOGIN_FAILURE) {
const result = message.payload;
console.log("Failed auth !!")
// Some actions
window.close(); // Want to close the popup window exactly here
}
});
}