c# - 我收到以下错误 "AADSTS90002 Tenant authorize not found."

标签 c# dynamics-crm azure-active-directory openid dynamics-365

我正在开发一个应用程序来获取数据 Dynamics 365 的 OAuth 为此,请使用以下示例

https://www.youtube.com/watch?v=Td7Bk3IXJ9s

public static async Task Auth()
{
    string URL = "https://grupolg.api.crm.dynamics.com/api/data/v9.1/";

    AuthenticationParameters API = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(URL)).Result;

                                                  //APP KEY, SECRET KEY
    ClientCredential Creds = new ClientCredential("hidden for security", "hidden for security"); 


    AuthenticationContext authContext = new AuthenticationContext(API.Authority);
    string token = authContext.AcquireTokenAsync(API.Resource, Creds).Result.AccessToken;

    using (HttpClient httpClient = new HttpClient())
    {
        httpClient.Timeout = new TimeSpan(0,2,0);
        httpClient.DefaultRequestHeaders.Authorization =
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer",token);

        HttpResponseMessage res = await httpClient.GetAsync(URL+"/contacts$top=1");
    }
}

但我收到以下错误:

enter image description here

最佳答案

该错误是由您使用的 ADAL 版本以及授权 URL 的生成方式引起的。

如果您将 Microsoft.IdentityModel.Clients.ActiveDirectory 库版本降级到 3.9.18,您将能够毫无问题地进行连接。有一个open bug in GitHub您可以在其中跟踪其进度或评论以添加更多信息以获得明确的修复。

关于c# - 我收到以下错误 "AADSTS90002 Tenant authorize not found.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54043862/

相关文章:

c# - Sendgrid X-SMTP-API 在使用 EnableTemplateEngine 时返回错误

dynamics-crm - 为 CRM 网格着色

azure - 使用客户端 key Azure 请求访问 token

c# - 为什么以相反的顺序调用构造函数?

c# - 在 EPPlus 中更改线条系列的颜色

javascript - 如何获取systemuser实体的值?

azure-active-directory - 使用 Azure AD 同意流程时出现空 GUID 错误

azure - 我无法删除 Azure AD 门户中的 native 应用程序注册

c# - VS 2013 当前不会命中断点。没有为该文档加载任何符号

reporting-services - 此代码对于字段中没有值的记录给出错误,但对于字段中具有值的记录给出良好的结果