0

How to retrieve Microsoft 365 security groups/members inside an SPFX web part?

Does anybody know how to do this or know of any tutorials? I am searching the internet with no luck.

enter image description here

0

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"
      }
    ]
2
  • 1
    Doesn’t your answer pre-suppose that GRAPH is enabled? Jan 28 '20 at 7:36
  • Yes I guess it does
    – BennKingy
    Jan 28 '20 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.