MSAL UserAgentApplication: Local storage not working

此生再无相见时 提交于 2019-12-04 04:33:56

问题


UserAgentApplication.localCache = "localStorage" is not working.

Steps to reproduce:

var client = new Msal.UserAgentApplication(config.aadClientId, config.aadAuthority...);

client.cacheLocation = "localStorage"; 

client.loginPopup().then( ... );

Result: The MSAL tokens are stored in session storage. (Chrome developer tools)

Expected: Tokens should be in local storage.

I am using msal 0.1.1 javascript library via https://secure.aadcdn.microsoftonline-p.com/lib/0.1.1/js/msal.min.js


回答1:


As a workaround we figured out that instantiating the Msal.Storage singelton before creating the UserAgentApplication, the local storage will be used. This is due to the fact, that when instantiating the UserAgenApplication the Msal.Storage is fixed configured with session storage. Therefore subsequent call of client.cacheLocation = "localStorage" doesn't not work, since the Msal.Storage is already created.

 ...
 new Msal.Storage("localStorage");

 var client = new Msal.UserAgentApplication(config.aadClientId, config.aadAuthority, ...);
 ...


来源:https://stackoverflow.com/questions/44114583/msal-useragentapplication-local-storage-not-working

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