简体   繁体   English

如何从Angular 7调用图AD API

[英]How to call graph AD api from Angular 7

after AD authentiction the returned JWT token does not have the group names, it just shows "Has groups"="true". 经过AD身份验证后,返回的JWT令牌没有组名,它仅显示“具有组” =“ true”。 When searching on this topic i understood that if there are multiple group it will send only this rather than group list and we need to use AD graph API to get this. 在搜索此主题时,我了解到,如果有多个组,它将仅发送此列表,而不发送组列表,我们需要使用AD图形API来获取此信息。 Can anyone help me on how to call the graph API from Angular 7? 有人可以帮助我如何从Angular 7调用图形API吗?

Want to get the group names of the particular user from Graph API 想要从Graph API获取特定用户的组名

You can just send a http request or use microsoft-graph-client library to call the graph api. 您可以只发送http请求,也可以使用microsoft-graph-client库调用图api。

Before that, you need to grant your app the needed permission. 在此之前,您需要授予您的应用所需的权限。 What you need is Directory.Read.All permission. 您需要的是Directory.Read.All权限。

Click Azure Active Directory->App registrations->find your application registered->API permissions->Add a permission->choose Microsoft Graph->Delegated permission->find Directory.Read.All permission->save-> click grant admin consent button. 单击Azure Active Directory->应用程序注册->查找应用程序已注册-> API权限->添加权限->选择Microsoft Graph->委托权限->查找Directory.Read.All权限-> save->单击授予管理员同意按钮。

在此处输入图片说明

Use http request: 使用http请求:

GET https://graph.microsoft.com/v1.0/me/memberOf

You can refer to this document . 您可以参考本文档

Use microsoft-graph-client library : 使用microsoft-graph-client库

import { Client } from '@microsoft/microsoft-graph-client';

graphClient.api('/me/memberOf').get();

Refer to this document for more details. 有关更多详细信息,请参阅此文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM