Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSAL UserAgentApplication: Local storage not working

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

like image 516
Marius Avatar asked Feb 19 '26 01:02

Marius


1 Answers

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, ...);
 ...
like image 105
Marius Avatar answered Feb 27 '26 09:02

Marius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!