使用客户端凭据的 Azure AD 服务到服务调用 - 共享 key

标签 azure azure-active-directory

我有一个托管在云上的 API 和一个守护程序应用程序客户端,该客户端位于同一组织和同一网络上,但位于我的本地计算机上。我对设置进行了两次和三次检查,但仍然无法将它们相互连接。

因此,为了查看这个问题,我将它们分为两个子问题。

  1. 将守护程序应用程序连接到 Azure AD,检索 token ,然后使用该 token 访问 Microsoft Graph。 检索 token 后出错。
Failed to call the Web Api: Forbidden
Content: {
  "error": {
    "code": "Authorization_RequestDenied",
    "message": "Insufficient privileges to complete the operation.",
    "innerError": {
      "request-id": "2646f5f8-9c25-482d-a89f-f14ca6c06cf7",
      "date": "2019-07-22T01:13:30"
    }
  }

我用过这个Azure DocumentSample产生上述错误。

Client API Permissions

  • 使用守护程序应用程序访问 API - 所以我从未接触过,因为我始终无法通过第 1 步。
  • 关于如何解决这个问题的任何想法。我错过了一些简单的事情吗?

    最佳答案

    Azure AD Graph APIMicrosoft Graph API 不同。因此有两种方法可以使其发挥作用。

    1使用 Microsoft Graph API

    您应该授予应用程序 microsoft graph api 权限。

    enter image description here

    2使用 Azure AD Graph API

    您需要更新以下代码。

    a.将范围更改为https://graph.windows.net/.default

    b.将 api 更改为 GET https://graph.windows.net/myorganization/users?api-version=1.6

    注意:

    We strongly recommend that you use Microsoft Graph instead of Azure AD Graph API to access Azure Active Directory resources.

    关于使用客户端凭据的 Azure AD 服务到服务调用 - 共享 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57153271/

    相关文章:

    azure - 在azure databricks中执行spark-submit而不创建新集群

    asp.net - 将 ASP.NET 应用程序部署到 Azure Web 应用程序,无需 .NET Core 和 Visual Studio

    mysql - 我可以通过 Azure 自动化中的 Runbook 将所有 Azure Active Directory 用户导出到 MySQL 数据库吗?

    Azure AD 将用户同步到本地 AD

    windows - 即使使用同一用户进行服务,也无法通过 Windows 服务访问 UNC 路径

    azure - 导出 Azure 服务总线配置导出

    c# - 使用 AAD 对 Azure API 应用程序进行身份验证时出现 401 错误

    azure - Power BI 始终返回 403 Forbidden

    c# - 如何使用 MS Graph API 获取组织中的所有部门

    c# - 更新 Azure Staging 部署将创建新的 url