How to retrieve Microsoft 365 security groups/members inside an SPFX web part?
-
08-02-2021 - |
Soluzione
The code below will list all the members of a office 365 security group or any group. The Group ID ({dab8006b-95f1-4df2-8704-004667d4b491}) is found by going into Azure > Groups.
Main component:
this.props.context.msGraphClientFactory
.getClient()
.then((client: MSGraphClient) => {
client.api('https://graph.microsoft.com/v1.0/groups/{dab8006b-95f1-4df2-8704-004667d4b491}/members')
.get((error, response:any, rawResponse?: any) => {
console.log('Graph', error);
console.log('Graph', response);
});
});
};
Package-solution.json:
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All"
}
]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange