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

1 Answer 1

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? Commented Jan 28, 2020 at 7:36
  • Yes I guess it does
    – BennKingy
    Commented Jan 28, 2020 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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