问题
How do I use LocalStorage with MSAL.js?
According to this, there's a property, cacheLocation, I need to set to 'localStorage'.
The following is still using sessionStorage:
var clientApplication = new Msal.UserAgentApplication(applicationConfig.clientID, applicationConfig.authority, function (errorDesc, token, error, tokenType) {
// Called after loginRedirect or acquireTokenPopup
});
clientApplication.cacheLocation = 'localStorage';
回答1:
Looks like the documentation is slightly out of date, see this GitHub issue: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/58. To set the cache location in the latest releases of msal.js, use the following pattern:
var userAgentApplication = new Msal.UserAgentApplication(applicationConfig.clientID, null, authCallback, { cacheLocation: 'localStorage' }); // to set it to localStorage
来源:https://stackoverflow.com/questions/45201872/how-to-use-localstorage-with-msal-js