問(wèn)題描述
我有一項(xiàng)服務(wù)使用我們使用 ADAL 檢索的 Azure 訪問(wèn)令牌.我們有數(shù)百個(gè)客戶,但由于某種原因,當(dāng)我們嘗試為他們檢索 AuthenticationResult
時(shí),其中有兩個(gè)偶爾會(huì)生成此錯(cuò)誤:
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:緩存包含多個(gè)令牌滿足要求.再次調(diào)用 AcquireToken 提供更多信息要求(例如 UserId).
multiple_matching_tokens_detected: The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements (e.g. UserId).
我不知道為什么數(shù)百人中只有這兩個(gè)人有這個(gè)問(wèn)題,而且在網(wǎng)上找不到太多關(guān)于它的信息.我們獲取令牌的代碼如下所示(簡(jiǎn)化):
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);
為什么會(huì)出現(xiàn)此錯(cuò)誤?解決此錯(cuò)誤的建議"解決方案是什么?我一直傾向于嘗試通過(guò)獲取這樣的令牌來(lái)修復(fù)它,但我真的很想知道錯(cuò)誤的真正含義:
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));
推薦答案
如果這仍然相關(guān),我有類似的問(wèn)題 multiple_matching_tokens_detected
錯(cuò)誤,我發(fā)現(xiàn)了這個(gè):
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 在回答中提到的那樣(您需要在客戶端機(jī)器上執(zhí)行此操作):
As Alex at the answer there mentioned (You need to do this on the client machine) :
- 關(guān)閉所有 Visual Studio 實(shí)例(在你的情況下 - 我想關(guān)閉所有客戶端應(yīng)用程序).
- 刪除 %LOCALAPPDATA%.IdentityService.
- 享受吧.
像魔術(shù)一樣為我工作
這篇關(guān)于使用 ADAL 檢測(cè)到的 multiple_matching_tokens_detected的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!