【发布时间】:2019-06-25 21:50:44
【问题描述】:
我有一个通过 OAuth 和 AzureAD 登录的网站。 我像这样获取我的 OAuth AuthenticationToken:
Claim tenantClaim = ClaimsPrincipal.Current.FindFirst(TenantIdClaimType);
if (tenantClaim != null)
{
string tenantId = tenantClaim.Value;
string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
AuthenticationContext authContext = new AuthenticationContext(Startup.Authority, new NaiveSessionCache(userObjectID));
ClientCredential credential = new ClientCredential(clientId, appKey);
AuthenticationResult authenticationResult = await authContext.AcquireTokenSilentAsync(dynamicsUrl, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
return authenticationResult.CreateAuthorizationHeader();
}
它一直运行良好。我失去了该网站大约 3 个月的跟踪,它不再工作了。我调试了我的代码并尝试“手动”进行。继续http://schemas.microsoft.com/identity/claims/tenantid,我看到了这条消息:
您要查找的资源已被删除,有它的名字 已更改,或暂时不可用。
它是被删除、重命名还是什么?我检查了 AzureAD,一切仍然有效(未过期)我什至创建了一个新的 appKey 并尝试了它,但它仍然无法正常工作。
我很抱歉我的英语不好我希望你们明白我在问什么,我在说什么。如果您需要更多信息,请告诉我。
感谢您抽出宝贵的时间,感谢您的帮助。
最好的问候, 尼科又名。万里达
【问题讨论】:
-
那个 schemas.microsoft.com 是一个 URI,而不是一个 URL。这只是一个标识符:)
-
您应该调试/记录用户可用的声明。
标签: oauth azure-active-directory claims