azure - 如何从 Azure AD 读取数据

标签 azure azure-active-directory microsoft-graph-api

我有一个网络应用程序。

某个组织的系统管理员登录到我的 Web 应用程序,并且需要能够将其组织中用户的电子邮件加载到该应用程序中。

系统管理员在 Azure AD 中管理其组织的用户。

在哪里可以找到此类集成的分步过程?

我了解我需要在 Azure 市场中创建一个应用程序,并且系统管理员需要授予我的应用程序的访问权限。只是找不到应该如何端到端完成此操作的确切步骤。

谢谢

最佳答案

I understand that I need to create an app in Azure marketplace and SysAdmin need to give access permissions for my app. Just can't find the exact steps how this should be done end to end.

您需要在租户中的任何组织目录(任何 Azure AD 目录 - Multi-Tenancy )中创建一个帐户应用程序:

enter image description here

并授予 User.Read.All 委派 API 权限:

enter image description here

确保通过与另一个租户管理员用户签名来授予租户广泛的管理员同意 API 权限:

https://login.microsoftonline.com/organizations/adminconsent?client_id=ClientIDofApp

enter image description here

其他租户中的企业应用程序现在已授予 API 权限(如果未授予此权限,则会出现 403 错误):

enter image description here

我使用以下端点来授权其他组织用户:

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize? 
client_id=ClientID
&response_type=code  
&redirect_uri=https://jwt.ms
&response_mode=query  
&scope=User.Read.All
&state=12345

我使用其他组织的管理员用户登录:

enter image description here

授权码已成功生成:

enter image description here

我通过 Postman 使用以下参数生成了访问 token :

https://login.microsoftonline.com/organizations/oauth2/v2.0/token

client_id:ClientID
scope:User.Read.All
grant_type:authorization_code
redirect_uri:https://jwt.ms
code:code
client_secret:ClientSecret

enter image description here

当我解码 token 时,会显示详细信息:

enter image description here

要获取管理员/其他组织中用户的电子邮件,请通过传递上述访问 token 来使用以下查询:

GET https://graph.microsoft.com/v1.0/users?$select=mail

enter image description here

引用:

Get a user - Microsoft Graph v1.0 | Microsoft

关于azure - 如何从 Azure AD 读取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76826811/

相关文章:

git - “找不到所选帐户的有效 Azure DevOps 团队项目”Azure Synapse GIT 配置

azure - 如何使用 Graph API 查找 azure AD guest 用户邀请是否已兑换

c# - 在启用 Azure 目录的情况下通过 Azure 代理访问本地 Api

azure - "Update User"操作在 Microsoft Graph API 中给出 "Insufficient privileges to complete the operation.' 错误

azure - 通过graph api或graph sdk为整个B2C实例创建用户自定义属性

.net - 是否可以通过代码在我的 Azure 帐户上创建新的 Web 应用程序和数据库?

c# - 查询表时Azure表过滤器和Linq有什么区别?

Azure B2C 与 Azure 外部身份

microsoft-graph-api - 如何在群聊中正确显示帖子内容?

Azure 流分析时间窗口查询