我有一项服务使用我们使用 ADAL 检索的 Azure 访问 token 。我们有数百个客户,但出于某种原因,当我们尝试为他们检索 AuthenticationResult
时,其中有两个偶尔会生成此错误:
multiple_matching_tokens_detected: The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements (e.g. UserId).
我不知道为什么数百人中只有这两个人有这个问题,而且在网上真的找不到太多关于它的信息。我们获取 token 的代码如下所示(已简化):
AuthenticationContext authContext = new AuthenticationContext(authority, new MyCustomTokenCache());
ClientCredential credential = new ClientCredential(myClientId, myPassword);
authContext.AcquireTokenSilent(resourceUri, credential, UserIdentifier.AnyUser);
为什么会出现此错误?解决该错误的“建议”解决方案是什么?我一直倾向于尝试通过获取这样的 token 来修复它,但我真的很想知道错误到底是什么:
authContext.AcquireTokenSilent(mr.ResourceUri, credential, new UserIdentifier("usersUPN@foo.com", UserIdentifierType.UniqueId));
最佳答案
如果这仍然相关,我遇到了与 multiple_matching_tokens_detected
错误类似的问题,我发现了这个:
正如 Alex 在答案中提到的那样(您需要在客户端计算机上执行此操作):
- 关闭所有 Visual Studio 实例(在您的情况下 - 我想关闭所有客户端应用程序)。
- 删除 %LOCALAPPDATA%\.IdentityService。
- 享受吧。
像魔术一样为我工作
关于c# - 使用 ADAL 检测到 multiple_matching_tokens_detected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32000185/