0

Can we call Graph API directly through MS Graph Client for SPFX tab in team Desktop??

Here is the sample of git which call Graph API directly in teams tab without any authentication flow or access token with only using Ms Graph Client Spfx tab with Graph API

1 Answer 1

1

In SPFx web part you will require to request permissions as below.

"webApiPermissionRequests": [
      {
        "resource": "Microsoft Graph",
        "scope": "Sites.ReadWrite.All"
      }
    
]

Once admin approve it you can call API using MSGraphClient.

Call graph api using MSGraphClient refer the below code.

export default class HelloWorldWebPart extends BaseClientSideWebPart<IHelloWorldWebPartProps> {
  public render(): void {
    // ...

    this.context.msGraphClientFactory
      .getClient()
      .then((client: MSGraphClient): void => {
        // use MSGraphClient here
      });
  }

  // ...
}
1
  • Thanks, I am able to achieve Graph API call in SPFX webpart and able to add that in Teams Tab but my question is that MS Graph Client is not working in Spfx team tab in Microsoft team DESKTOP Apr 26, 2022 at 7:04

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.