Ms Graph With SPFx Part 1

Step 7 : Render method looks like as below.
I am not adding to make the structure ready and pass as input to Detail list which is Office Fabric UI React Control. You can get solution how to pass the data to Control using below URL.
Office Fabric UI React Control Detail list

Render method looks like as below

public render():React.ReactElement<{}>{
    <div className={styles.reactGroupSamples}>
          titleText='Select Group:'
          principalTypes={[PrincipalType.DistributionList, PrincipalType.SecurityGroup]}
          resolveDelay={1000} />
      <p className={styles.memberStatus}>Group ID: {this.state.GroupId}</p>
      {this.state.loading &&
          <Spinner label='Loading...' ariaLive='assertive' />
      {this.state.userItems.length > 0 &&
        <div className={styles.detailsList}>
          <div className={styles.row}>
            <div className={styles.column}>
                  label='Filter by Name:'
            <div className={styles.column}>
          <div className={styles.row}>
            <div className={styles.column}>
              <p className={styles.memberStatus}>Group ID: {this.state.GroupId}</p>
            <div className={styles.column}>
                  <CSVLink className={styles.csvLink}
                    <CommandBarButton className={styles.exportIcon} iconProps={{ iconName: 'ExcelLogoInverse' }} text='Export to Excel' />
              ariaLabelForSelectionColumn='Toggle selection'
              ariaLabelForSelectAllCheckbox='Toggle selection for all items'
              checkButtonAriaLabel='Row checkbox'
      <p className={styles.memberStatus}>{this.state.memberStatus}</p>

Step 8 : Open Package.solution file and make below changes
Please make sure isDomainIsolated:true.
This property provide the security. Graph API Access concented only for this webpart.
So if any other webpart use Graph API then access i not granted.
If you use isDomainIsolated:false then number of webparts can use Graph API access.

  "$schema": "",
  "solution": {
    "name": "react-group-samples-client-side-solution",
    "id": "84bd4efc-eec8-4c97-84ee-b95d981b880b",
    "version": "",
    "includeClientSideAssets": true,
    "isDomainIsolated": true,
    "webApiPermissionRequests": [
        "resource": "Microsoft Graph",
        "scope": "Directory.Read.All"
        "resource": "Microsoft Graph",
        "scope": "Group.Read.All"
  "paths": {
    "zippedPackage": "solution/react-group-samples.sppkg"

Step 9 : Run below commands to generate the package .pkg file.

gulp bundle --ship
gulp package-solution --ship

Step 10 : Deploy package file in to app catalogs.
Click here to know how to deploy package file in sharepoint online.

Step 11 : Once the solutions is uploaded. Open below link to Approve the API request which is send by SharePoint Framework web part to Admin user. To approve the request we must have a the tenant administrator access.

Step 11 : Once the API request is approved.
Go to the sharepoint site and add webpart to page.You will get output as below image.

Output of web part

Please let me know your feedback and i am writing series of demos regarding the Graph API and SPFx integration.
You can contact me on Facebook, twitter or linkedin.

Sharing is Caring 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.