azure - 如何从 Azure Active Directory 获取 postman 中的用户角色声明?

标签 azure azure-active-directory

我在我的 Azure AD 帐户中添加了一些用户,我想通过以声明的形式从 Postman 调用 Azure API 来获取这些用户的角色和用户信息。我尝试使用以下参数调用以下 URL:

https://login.microsoftonline.com/myTenantId/oauth2/token

正文: grant_type :密码, client_id :客户端 ID, 客户端 secret :客户端 secret

当我在https://jwt.io/上解码它时,我在响应中收到编码格式的access_token我看到了解码后的数据,但 access_token 中没有用户角色。

我想在同一响应中以声明的形式获取用户信息和角色。

我需要采取什么方法来解决这个问题?

最佳答案

如果你提到的角色是指目录角色,答案是否定的,它不会在 token 中返回。就像juunas说的,你可以调用graph api to get directory role信息。

enter image description here

如果你提到的角色是指应用角色,那么答案是肯定的,你可以在id_token中获取角色信息。 先决条件是您拥有 assigned some roles to the user .

enter image description here

以下是详细步骤。您也可以引用this article .

  1. 编辑 list 以添加一些自定义角色。

enter image description here

类似这样的事情。

{
      "allowedMemberTypes": [
        "User"
      ],
      "displayName": "Test",
      "id": "c200e304-fff3-49f1-a4df-e406741ea680",
      "isEnabled": true,
      "description": "Bla bla",
      "value": "test"
    }

2. assign users to roles 。 单击企业应用程序->所有应用程序-> enter image description here

单击您的应用程序 -> 单击用户和组 -> 单击添加用户 enter image description here

角色分配。

enter image description here

这里是获取id_token的请求。 enter image description here

您将在 id_token 中找到角色。 enter image description here

关于azure - 如何从 Azure Active Directory 获取 postman 中的用户角色声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55492629/

相关文章:

azure - Azure VNET 中的子网地址范围确定

c# - 使用 IWA 从 Excel 加载项访问 Azure AD

azure - 移动设备上的 Windows Azure Active Directory 身份验证速度缓慢

azure - Azure 上的 Axe - 与本地客户端的连接

ssl - 无法让 SSL 在 Azure 实例上运行

azure - 源参数未指定蛋糕

javascript - Power BI API 身份验证

c# - Azure AD 签名 key 滚动更新

Azure AD B2C : The redirect URI provided in the request is not registered for the client id. ..但实际上是

azure - 如何将包含 secret API key 的公共(public) Github 项目部署到 Azure?