问题
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