MSAL UserAgentApplication:本地存储不起作用 [英] MSAL UserAgentApplication: Local storage not working

查看:291
本文介绍了MSAL UserAgentApplication:本地存储不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UserAgentApplication.localCache ="localStorage"无法正常工作.

UserAgentApplication.localCache = "localStorage" is not working.

复制步骤:

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

client.cacheLocation = "localStorage"; 

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

结果: MSAL令牌存储在会话存储中. (Chrome开发者工具)

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

预期: 令牌应位于本地存储中.

Expected: Tokens should be in local storage.

我正在通过推荐答案

作为一种解决方法,我们发现在创建UserAgentApplication之前实例化Msal.Storage singelton,将使用本地存储.这是由于以下事实:在实例化UserAgenApplication时,Msal.Storage是固定配置的,具有会话存储.因此,随后的client.cacheLocation ="localStorage"调用不起作用,因为已经创建了Msal.Storage.

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, ...);
 ...

这篇关于MSAL UserAgentApplication:本地存储不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆