使用@azure/Msal-browser时,我在ClientAuthError上收到此错误消息:state_not_found:未找到状态

问题描述 投票:0回答:2

我正在使用

http://localhost
create-react-app
上开发使用 @azure/msal-browser,当尝试通过
msal.loginRedirect()
登录时,浏览器会重新调整到该网站,并且页面正确,但用户未登录,并且出现以下内容错误出现在控制台中(来自 handleRedirectPromise 方法)
ClientAuthError: state_not_found: State not found:  Cached State

状态参数is传递到登录网址(https://login.microsoft.com...state=base64string...),但本地/会话/Cookie 存储中没有任何内容。

Azure 应用程序配置很好(之前使用过),但有些东西没有使用 msal 库进行工作/配置,有什么想法吗?

typescript azure create-react-app azure-ad-msal
2个回答
4
投票

如果handleRedirectPromise被调用两次,就会导致这个错误。 msal-react 应该为您调用此函数,因此无需您自己进行此调用。有关详细信息,请参阅此 github 问题:msal-browser 重定向无法正常工作


0
投票

当使用顶级记录器上下文包装 MSAL 提供程序时,我在 NextJS 应用程序中遇到此错误。问题在于记录器上下文中的

useEffect
使用 - 它生成了不正确的渲染顺序,因此页面因错误
state_not_found
no_cached_authority_error
而崩溃 - 取决于我的 MSAL 模块代码库。希望它可以对某人有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.