問題描述
我有一項服務使用我們使用 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) :
- 關閉所有 Visual Studio 實例(在你的情況下 - 我想關閉所有客戶端應用程序).
- 刪除 %LOCALAPPDATA%.IdentityService.
- 享受吧.
像魔術一樣為我工作
這篇關于使用 ADAL 檢測到的 multiple_matching_tokens_detected的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!