How To Use LocalStorage with MSAL.js

China☆狼群 提交于 2020-01-04 04:45:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!