【问题标题】:Azure Active Directory and avocado api authenticationAzure Active Directory 和 avocado api 身份验证
【发布时间】:2017-01-06 17:41:22
【问题描述】:

我有下面的代码

string aadInstance = "https://login.windows.net/{0}";
string tenant = "<tenant>.onmicrosoft.com";
string clientId = "d22d1d2a-...";
Uri redirectUri = new Uri("http://redirect");

string authority = String.Format(aadInstance, tenant);
string apiResourceId = "https://<resource>.onmicrosoft.com/sample";
string apiBaseAddress = "http://localhost:9003/";

AuthenticationContext authContext = authContext = new AuthenticationContext(authority);
AuthenticationResult authResult = authContext.AcquireToken(apiResourceId, clientId, redirectUri);

我已将应用程序作为本机应用程序添加到活动目录中,但出现错误。 “AADSTS50001:在名为 .onmicrosoft.com 的租户中找不到名为 .onmicrosoft.com/sample">https://.onmicrosoft.com/sample 的应用程序。如果租户管理员未安装应用程序或未获得租户中任何用户的同意,则可能会发生这种情况。您可能将身份验证请求发送给了错误的租户。”

我对 apiresource id 应该是什么感到困惑,如果可能的话,请给我关于如何在本机和 web api 应用程序中配置应用程序的快照,资源 id 和租户 id 名称应该在哪里等等,我我也对“其他应用程序的权限”感到困惑,我正在搜索不可见的“鳄梨”。

【问题讨论】:

    标签: c# azure


    【解决方案1】:

    根据错误消息,您在请求访问令牌时似乎使用了不正确的资源

    resource应该是原生应用所使用的web API的APP ID URI,你可以通过旧的portal找到它,如下图:

    我们也可以通过 Azure Active Directory->App registrations->{You app}->Properties 在新门户中找到它:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-11
      • 2017-09-05
      • 2016-01-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-15
      • 2018-03-20
      • 1970-01-01
      相关资源
      最近更新 更多