I'm developing a SharePoint extension (ListViewCommandSet extension).

I have no clue (can't find any docs about this) how to give permissions to access Graph API (even the /me call gives a 403 response).

Any ideas of how to access the Graph API from localhost when developing a SPFX extension?


The Leverage the Microsoft Graph & 3rd Party APIs training module shows how to configure your project to use the Microsoft Graph. The training module shows how to do so in a web part project, but the same process can be used when building a SharePoint Framework extension.

SharePoint Framework projects that call to the Microsoft Graph cannot be tested or debugged in the local workbench. They can be tested and debugged in the hosted workbench, but only after the requested permissions have been granted in the SharePoint Online Admin Center.

  • 1
    thx for answering. So, do I have to deploy de extension first? What about hot reloading? Feb 24 '20 at 10:28
  • If the Microsoft Graph permissions needed by your extension have already been granted tenant-wide then you do not need to deploy the extension first. You can immediately test as you would if your extension did not use the Microsoft Graph. If the permissions needed by your extension have not yet been granted, then you need to deploy the package to the app catalog, grant the permissions in the SharePoint Admin Center, and then test. All of this is covered in the training module I linked in my answer. Feb 24 '20 at 11:03
  • Thank you, Rob. I discovered that yesterday after your first response. it should be in more explicitly explained in the docs Feb 25 '20 at 12:18

Do you use PnPjs, if so, which version?

Microsoft Graph API is accessible with PnPjs. You have to install the following packages with npm :

npm install @pnp/logging @pnp/common @pnp/odata @pnp/graph --save

This guide details this part.

  • I presonally prefear to use the Graph API directly by doing the request through the browser' fetch api, but thanks for answering Feb 25 '20 at 15:22

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.