首页 > 解决方案 > MSAL 以静默方式获取令牌在 IE 11 for React SPA 中不起作用

问题描述

为了支持 IE 11,我包括以下内容:

import 'react-app-polyfill/ie11';

还禁用了保护模式以便在本地运行应用程序(参考Microsoft 的文档

现在我可以登录并执行操作,但是静默获取令牌不起作用。我使用本地存储作为 cacheLocation 并且还发现所有内容都存储在本地存储中。但是,每当我尝试静默获取令牌时,都会出现错误。成功登录后,如果我关闭浏览器并在 IE 11 中重新打开应用程序,那么我希望我的应用程序将静默获取令牌,但它永远不会在 IE 11 中发生(在 chrome 和 edge 中工作正常)。它总是无法以静默方式获取令牌,并出现以下错误:

InteractionRequiredAuthError: Silent authentication was denied. The user must first sign in and if needed grant the client application access to the scope 'user.read openid profile'.

在浏览器控制台中,我收到另一个错误:

Error occurred in token received callback function. TypeError: Object expected.

这两个错误都只发生在 IE 11 中,并且在 chrome/edge 中完美运行。

标签: reactjsauthenticationinternet-explorermsal

解决方案


推荐阅读