How to use LocalStorage with MSAL.js

How to use LocalStorage with MSAL.js ?

According to this , there is a property, cacheLocation, I need to set to 'LocalStorage'.

Next, sessionStorage is used:

var clientApplication = new Msal.UserAgentApplication(applicationConfig.clientID, applicationConfig.authority, function (errorDesc, token, error, tokenType) {
        // Called after loginRedirect or acquireTokenPopup
    });
clientApplication.cacheLocation = 'localStorage';
+3
source share
1 answer

The documentation seems to be a bit dated, see this GitHub issue: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/58 . To set the cache location in recent versions of msal.js, use the following template:

var userAgentApplication = new Msal.UserAgentApplication(applicationConfig.clientID, null, authCallback, { cacheLocation: 'localStorage' }); // to set it to localStorage
+3
source

Source: https://habr.com/ru/post/1687650/


All Articles