Azure Graph API - 查询用户信息
Azure Graph API - Query user information
我正在尝试弄清楚如何使用 Azure Graph API 从给定的用户名查询用户的全名(名字和姓氏)。我知道我可以使用以下图表 API 调用...
https://graph.windows.net/myorganization/users/{user_id}?api-version
但是,我不确定如何获取访问令牌以用于此,因为将在没有用户登录的情况下调用此过程,这通常是我们获取访问令牌的方式。
我是否可以使用 cURL 或其他方式将 username/password 传递给给定的 URL 并以这种方式获得访问令牌,所以它是在背后完成的 -场景?
OAuth 2 支持两种主要的身份验证方法:
第一个流程需要用户代理在场才能登录客户端服务,并生成 委托令牌 。第二种方法不需要用户登录,因为它只使用客户端密码进行身份验证;这导致 app only token.
如果您想要创建从 AAD Graph API 捕获数据的后台服务,您完全可以使用客户端凭据授予流程来完成此操作,它不需要用户在任何时候都在场在身份验证流程中。
您只需将您的应用程序配置为具有 仅应用范围。阅读here: Permission scopes | Graph API concepts。仅应用程序范围都需要租户管理员同意该应用程序才能访问数据。
最后,我觉得我必须提到 OAuth 2 规范中指定的另一个较少使用的流程:Resource Owner Password Credentials Grant。此流程指定了解用户用户名和密码的客户端应用程序如何直接传递这些参数并代表用户获取访问令牌。但是,使用此流程根本不是一个好的做法。
The resource owner password credentials grant type is suitable in
cases where the resource owner has a trust relationship with the
client, such as the device operating system or a highly privileged
application. The authorization server should take special care when
enabling this grant type and only allow it when other flows are not
viable.
我们在 V1 端点中支持此功能,但在新的 V2 端点中不支持。你可以阅读 this blog to learn more.
我正在尝试弄清楚如何使用 Azure Graph API 从给定的用户名查询用户的全名(名字和姓氏)。我知道我可以使用以下图表 API 调用...
https://graph.windows.net/myorganization/users/{user_id}?api-version
但是,我不确定如何获取访问令牌以用于此,因为将在没有用户登录的情况下调用此过程,这通常是我们获取访问令牌的方式。
我是否可以使用 cURL 或其他方式将 username/password 传递给给定的 URL 并以这种方式获得访问令牌,所以它是在背后完成的 -场景?
OAuth 2 支持两种主要的身份验证方法:
第一个流程需要用户代理在场才能登录客户端服务,并生成 委托令牌 。第二种方法不需要用户登录,因为它只使用客户端密码进行身份验证;这导致 app only token.
如果您想要创建从 AAD Graph API 捕获数据的后台服务,您完全可以使用客户端凭据授予流程来完成此操作,它不需要用户在任何时候都在场在身份验证流程中。
您只需将您的应用程序配置为具有 仅应用范围。阅读here: Permission scopes | Graph API concepts。仅应用程序范围都需要租户管理员同意该应用程序才能访问数据。
最后,我觉得我必须提到 OAuth 2 规范中指定的另一个较少使用的流程:Resource Owner Password Credentials Grant。此流程指定了解用户用户名和密码的客户端应用程序如何直接传递这些参数并代表用户获取访问令牌。但是,使用此流程根本不是一个好的做法。
The resource owner password credentials grant type is suitable in cases where the resource owner has a trust relationship with the client, such as the device operating system or a highly privileged application. The authorization server should take special care when enabling this grant type and only allow it when other flows are not viable.
我们在 V1 端点中支持此功能,但在新的 V2 端点中不支持。你可以阅读 this blog to learn more.