[英]Authentication to Azure Active Directory and receive AADSTS90019 error
I am trying to authenticate against AAD using the following code:我正在尝试使用以下代码对 AAD 进行身份验证:
string userName = "something.com"; //(just an example)
string password = "IafksdfkasdaFadad=asdad=a="; //(just an example)
string clientId = "6cd6590f-4db9-4c6b-98d1-476f9e90912f"; //(just an example)
var credentials = new UserPasswordCredential(userName, password);
var authenticationContext = new AuthenticationContext("https://login.windows.net/common");
var result = await authenticationContext.AcquireTokenAsync("https://api.partnercenter.microsoft.com", clientId, credentials);
return result;
and I got AADSTS90019 error: No tenant-identifying information found in either the request or implied by any provided credentials.我收到 AADSTS90019 错误:在请求中或任何提供的凭据中都找不到租户识别信息。
As a remark, it is just a console application made in Visual Studio using C#.作为备注,它只是在 Visual Studio 中使用 C# 制作的控制台应用程序。
Based on the information from https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes the explication for AADSTS90019 error is: MissingTenantRealm - Azure AD was unable to determine the tenant identifier from the request .根据来自https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes的信息,AADSTS90019 错误的解释是: MissingTenantRealm - Azure 无法确定 AD请求中的租户标识符。
So, my question is: What is the tentant identifier and how should I use it in my request?所以,我的问题是:什么是 tentant 标识符,我应该如何在我的请求中使用它? Should it be the one from the following screenshot?
它应该是以下屏幕截图中的那个吗? The screenshot is made from the Azure account.
截图来自 Azure 账户。
Azure Application Overview Azure 应用概述
Any information can help.任何信息都可以提供帮助。
Thank you.谢谢你。
You should initialize your authentication context with a tenant-specific authority instead of common:您应该使用特定于租户的权限而不是通用权限来初始化您的身份验证上下文:
var authenticationContext = new AuthenticationContext("https://login.microsoftonline.com/your-directory-id");
Replace your-directory-id
with your Directory (tenant) id.将
your-directory-id
替换为您的目录(租户)ID。
var authenticationContext = new AuthenticationContext("https://login.windows.net/common");
Here Replace the string "common" with the tenant name.此处将字符串“common”替换为租户名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.