【问题标题】:AADSTS90002: Tenant 'xx' not found. This may happen if there are no active subscriptions for the tenantAADSTS90002:未找到租户“xx”。如果租户没有活动订阅,则可能会发生这种情况
【发布时间】:2021-09-12 03:40:04
【问题描述】:

我按照this 教程从客户端应用程序为目标应用程序生成访问令牌。根据本教程的评论,对于resources,我更改为App ID URL。但我仍然无法为目标应用成功生成不记名令牌。

它显示此错误消息:

Adal异常: {"error":"invalid_request","error_description":"AADSTS90002: 租户 '' 未找到。如果没有活动,可能会发生这种情况 租户的订阅......}

有人知道我还错过了什么吗?

【问题讨论】:

  • 1) 正如错误所说,请确保您使用正确的tenantId 或名称,例如 xyz.onmicrosoft.com,尤其是在指定 authority 时共享您的权限值'尽可能在此处使用(删除任何敏感信息)2) 教程有点旧,您使用的是什么版本的 ADAL Microsoft.IdentityModel.Clients.ActiveDirectory3) 您是如何注册申请的? Azure 门户 https://portal.azure.comhttps://apps.dev.microsoft.com/
  • 回答你的问题,1)权限正确2)4.5.13)portal.azure.com
  • ok 有道理.. 对于resource,当您说您正在使用 App ID URL 时.. 您从哪里得到它?理想情况下,它应该是您为其获取令牌的目标应用程序的 App ID URI 值。要获取该值,请转到 Azure 门户 > Azure AD > 目标应用程序注册 > 设置 > 属性,您应该在那里看到 App ID URI。值应该完全匹配.. 另外,只是为了确认一下,当 context.AcquireTokenAsync( resource, clientCredential); 被执行时,您会收到该错误?
  • 感谢您的帮助,我从客户端应用程序输入了错误的 App ID URI..

标签: azure asp.net-core oauth-2.0 azure-active-directory


【解决方案1】:

对我来说,问题已通过使用旧版本的 Microsoft.IdentityModel.Clients.ActiveDirectory 得到解决。 我不得不使用 3.13.8 版本。最新版本有问题。

【讨论】:

  • 你是救世主!!
  • 2020年11月依旧如此!
  • 此修复在 2021 年 3 月仍然适用
【解决方案2】:

使用 ADAL 通过客户端凭据流获取访问令牌:

AuthenticationContext authenticationContext =
       new AuthenticationContext("https://login.microsoftonline.com/<tenantId>");

ClientCredential clientCredential = new ClientCredential(clientId, appKey);
AuthenticationResult result =
       await authenticationContext.AcquireTokenAsync("https://resourceUrl",
                                                         clientCredential);

参考:https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki/Client-credential-flows

还有文件:Service to service calls using client credentials

【讨论】:

  • 您是否设置了正确的租户 ID 或名称?要查找您的租户 ID,请单击 Azure Active Directory -->Properties-->Directory ID
  • @WWpana 也试试这个:string Instance = "login.microsoftonline.com{0}"; string authority = string.Format(CultureInfo.InvariantCulture, Instance, "xxxx.onmicrosoft.com"); AuthenticationContext authenticationContext = new AuthenticationContext(authority);
  • 我成功了!我输入了错误的租户 ID :( 感谢您的帮助!
【解决方案3】:

在我的情况下,我将客户端 ID (xxxxx-xxx-xxxx-xxxx-xxxxxxx) 误认为租户 ID (myproject.onmicrosoft.com)

【讨论】:

    猜你喜欢
    • 2018-12-06
    • 2019-05-08
    • 2019-04-29
    • 2019-11-22
    • 1970-01-01
    • 2019-08-24
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多