gpt4 book ai didi

asp.net-core - 重启后找不到账号 : No account or login hint was passed to the AcquireTokenSilent call

转载 作者:行者123 更新时间:2023-12-04 12:59:26 27 4
gpt4 key购买 nike

我有一个 Web 应用程序,它必须向 API 发送 B2C 承载 token 才能获得授权。我通过使用 MSAL 实现了这一点,一切正常,直到我重新启动 Web 应用程序,一旦我重新启动 Web 应用程序(不注销),似乎 应用程序仍能找到 B2C 声明,并且用户仍处于登录状态 ,但是 IConfidentialClientApplication 无法使用 GetAccountAsync(),因为找不到帐户 .

The Error I get is: {"No account or login hint was passed to the AcquireTokenSilent call."}



如果用户注销,问题就解决了。这发生在本地主机上,如果应用程序是使用 Azure 发布的并且我重新启动应用程序服务,也会发生这种情况。

最佳答案

正如 juunas 在评论中解释的那样,MSAL 使用 an in memory token cache by default .

一旦客户端登录,身份验证信息将存储在 cookie 中(如果 cookie 未禁用)。即使您的 Web 应用程序重新启动,客户端也会保持登录状态。

但是,由于使用了内存缓存,如果应用程序重新启动,所有缓存的项目都将被清除。要解决这个问题,您可以custom token cache serialization in MSAL.NET .

关于asp.net-core - 重启后找不到账号 : No account or login hint was passed to the AcquireTokenSilent call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60524263/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com