调用 Microsoft Graph API 获取 Angular 中的用户 AD 组 7
Calling Microsoft Graph API to get the users AD group in Angular 7
我们需要从 Angular 7 应用程序调用 Microsoft graph API 以获取用户 AD 组的详细信息。
我们已经在 Azure AD 中注册了应用程序,并且我们已经阅读了 Azure Active Directory Graph 和 Microsoft Graph 的 API 权限。
现在我们要验证我们是否能够在 post man 中访问图 api。任何人都可以帮助如何在 post man.
中进行测试
如果有任何示例代码可以从 Angular 7 应用程序
中调用图 api,那将会很有帮助
您可以参考以下步骤在Postman中进行测试:
Register an application with the Microsoft identity platform. I believe that you have completed this step. But you still need to do more configuration. Get group requires these permissions。我将在这里使用委托权限:Group.Read.All。在 Azure 门户上 -> 你的 Azure AD 应用 -> API 权限 -> 添加权限 -> Microsoft Graph -> 委派权限。
添加此权限后,不要忘记点击"Grant admin consent for {your tenant}"。 (从配置权限到它们出现在同意提示中之间存在延迟。请等待几分钟,然后再授予管理员同意)
您需要添加一个client secret以备后用(拿到后记录下来,离开本页后将不可见):
接下来你可以 Get authorization。只需在您的浏览器中访问此 url:
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id={client id of your Azure AD app}
&response_type=code
&redirect_uri={redirect uri of your Azure AD app}
&response_mode=query
&scope=offline_access Group.Read.All
&state=12345
使用您的帐户登录,您将在地址栏的响应中收到 code
。
现在打开 Postman 到 get a token。生成这样的请求:
获取访问令牌后,您可以调用GET https://graph.microsoft.com/v1.0/groups
或GET https://graph.microsoft.com/v1.0/groups/{group id}
获取AD组详细信息。
请注意Authorization的取值格式为:"bearer {access_token}"。在"bearer"和“{access_token}”之间有一个space。
这里有一些Angular code samples for Microsoft Graph供大家参考。
我们需要从 Angular 7 应用程序调用 Microsoft graph API 以获取用户 AD 组的详细信息。
我们已经在 Azure AD 中注册了应用程序,并且我们已经阅读了 Azure Active Directory Graph 和 Microsoft Graph 的 API 权限。
现在我们要验证我们是否能够在 post man 中访问图 api。任何人都可以帮助如何在 post man.
中进行测试如果有任何示例代码可以从 Angular 7 应用程序
中调用图 api,那将会很有帮助您可以参考以下步骤在Postman中进行测试:
Register an application with the Microsoft identity platform. I believe that you have completed this step. But you still need to do more configuration. Get group requires these permissions。我将在这里使用委托权限:Group.Read.All。在 Azure 门户上 -> 你的 Azure AD 应用 -> API 权限 -> 添加权限 -> Microsoft Graph -> 委派权限。
添加此权限后,不要忘记点击"Grant admin consent for {your tenant}"。 (从配置权限到它们出现在同意提示中之间存在延迟。请等待几分钟,然后再授予管理员同意)
您需要添加一个client secret以备后用(拿到后记录下来,离开本页后将不可见):
接下来你可以 Get authorization。只需在您的浏览器中访问此 url:
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id={client id of your Azure AD app}
&response_type=code
&redirect_uri={redirect uri of your Azure AD app}
&response_mode=query
&scope=offline_access Group.Read.All
&state=12345
使用您的帐户登录,您将在地址栏的响应中收到 code
。
现在打开 Postman 到 get a token。生成这样的请求:
获取访问令牌后,您可以调用GET https://graph.microsoft.com/v1.0/groups
或GET https://graph.microsoft.com/v1.0/groups/{group id}
获取AD组详细信息。
请注意Authorization的取值格式为:"bearer {access_token}"。在"bearer"和“{access_token}”之间有一个space。
这里有一些Angular code samples for Microsoft Graph供大家参考。