2017-07-19 62 views
2

如何使用LocalStorage與MSAL.js如何在MSAL.js中使用LocalStorage

根據this,有一個屬性,cacheLocation,我需要設置爲'localStorage'。

依然採用的sessionStorage以下:

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

回答

1

貌似文檔略顯過時,看到這個問題的GitHub:https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/58。要設置緩存位置msal.js的最新版本,請使用以下模式:

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

這GitHub上的問題讓我到相關的SO發出https://stackoverflow.com/questions/44114583/msal-useragentapplication - 本地存儲 - 不工作/ 44133641#44133641 – spottedmahn