使用 ADAL 检测到的 multiple_matching_tokens_detected

时间:2023-02-18
本文介绍了使用 ADAL 检测到的 multiple_matching_tokens_detected的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一项服务使用我们使用 ADAL 检索的 Azure 访问令牌.我们有数百个客户,但由于某种原因,当我们尝试为他们检索 AuthenticationResult 时,其中有两个偶尔会生成此错误:

I have a service that uses Azure access tokens that we retrieve using ADAL. We have several hundred customers, but for some reason there are two of them that sporadically generate this error when we try to retrieve an AuthenticationResult for them:

multiple_matching_tokens_detected:缓存包含多个令牌满足要求.再次调用 AcquireToken 提供更多信息要求(例如 UserId).

multiple_matching_tokens_detected: The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements (e.g. UserId).

我不知道为什么数百人中只有这两个人有这个问题,而且在网上找不到太多关于它的信息.我们获取令牌的代码如下所示(简化):

I have no idea why only these two folks out of hundreds have this issue and really can't find much about it on the net. Our code to acquire a token looks like this (simplified):

AuthenticationContext authContext = new AuthenticationContext(authority, new MyCustomTokenCache());
ClientCredential credential = new ClientCredential(myClientId, myPassword);
authContext.AcquireTokenSilent(resourceUri, credential, UserIdentifier.AnyUser); 

为什么会出现此错误?解决此错误的建议"解决方案是什么?我一直倾向于尝试通过获取这样的令牌来修复它,但我真的很想知道错误的真正含义:

Why does this error occur and what is the "suggested" solution to resolve it? I have been leaning towards trying to fix it by acquiring a token like so but really would like to know what the error really is all about:

authContext.AcquireTokenSilent(mr.ResourceUri, credential, new UserIdentifier("usersUPN@foo.com", UserIdentifierType.UniqueId));

推荐答案

如果这仍然相关,我有类似的问题 multiple_matching_tokens_detected 错误,我发现了这个:

If this is still relevant, I had similar problem with multiple_matching_tokens_detected error and I found this:

https://developercommunity.visualstudio.com/content/problem/17315/cant-add-new-account-with-vsts-online-failed-to-re.html

正如 Alex 在回答中提到的那样(您需要在客户端机器上执行此操作):

As Alex at the answer there mentioned (You need to do this on the client machine) :

  1. 关闭所有 Visual Studio 实例(在你的情况下 - 我想关闭所有客户端应用程序).
  2. 删除 %LOCALAPPDATA%.IdentityService.
  3. 享受吧.

像魔术一样为我工作

这篇关于使用 ADAL 检测到的 multiple_matching_tokens_detected的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:如何配置 Azure AD 访问令牌的过期时间(使用 ADAL)? 下一篇:.net 核心中的混合身份验证与 Open Id Connect 和本地数据库

相关文章

最新文章