如何将LocalStorage与MSAL.js一起使用?
根据this,有一个属性cacheLocation,我需要设置为' localStorage'。
以下内容仍在使用sessionStorage:
var clientApplication = new Msal.UserAgentApplication(applicationConfig.clientID, applicationConfig.authority, function (errorDesc, token, error, tokenType) {
// Called after loginRedirect or acquireTokenPopup
});
clientApplication.cacheLocation = 'localStorage';
答案 0 :(得分:2)
看起来文档略有过时,请参阅此GitHub问题:https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/58。要在最新版本的msal.js中设置缓存位置,请使用以下模式:
var userAgentApplication = new Msal.UserAgentApplication(applicationConfig.clientID, null, authCallback, { cacheLocation: 'localStorage' }); // to set it to localStorage