I'm getting 403 forbidden error in my SPFx web part when trying to access Teams presence (mine and other users as well). I have set permissions in package-solution:


    "resource": "Microsoft Graph",
    "scope": "Presence.Read"  
    "resource": "Microsoft Graph",
    "scope": "Presence.Read.All" 

Call for presence:

.then((client: MSGraphClient) => {

    .get((err, res) => {  
      if (err) {

Any idea what is wrong please?


You can also get the user's presence using MSGraphClient in SPFx.

Get the Graph Client using:

import { MSGraphClient } from '@microsoft/sp-http';

private _graphHttpClient: MSGraphClient;

return new Promise((resolve, reject) => {
      this.context.msGraphClientFactory.getClient().then(client => {
        this._graphHttpClient = client;
      }).catch(error => {

Then you can get the presence of user using:

const endpoint: string = `https://graph.microsoft.com/beta/communications/getPresencesByUserId`;
const response: any = await this.props.graphHttpClient.api(endpoint).post({
    "ids": users  //Here you need to pass the user ID's
const graphResponse: any = response.value;

Check the complete code at GitHub SPFx webpart sample:

Reference: react-members-with-presence.

  • Thanks, but it's still the same :( . I get: POST https://graph.microsoft.com/beta/communications/getPresencesByUserId 403 (Forbidden). Is getting presence even available already? It's still beta. I have seen notify like that: "Use of these APIs in production applications is not supported." here: link – Vochomurka Mar 2 '20 at 11:03
  • Yes, it is in beta and not supported for production environments. If you are planning to use this in production environment then I will suggest you to don't use it. Also, are you tenant administrator? – Ganesh Sanap Mar 2 '20 at 12:49
  • Not tenant, but I'm SharePoint admin. What is meant by "production enviroment"? Are there any other uses of getting presence then in public apps? Is it only for testing so far when we can't use this publicly? It's little bit confusing for me. – Vochomurka Mar 2 '20 at 12:52

You need to approve the permissions in your SharePoint admin center first before you can make Graph requests, and each Graph permission you need will require approval.

Create a package to upload to your Apps library (it doesn't matter that it isn't ready for deployment) and then after you've done that, go to SharePoint admin and go to the API Access under advanced, then look for your Graph permissions and approve them. I shared an image of my admin with permission waiting for approval

Now you can get back to building out your spfx and testing the web calls without getting 403 :)

edit Your spfx package must have the permissions you require in the package-solution.json before you upload it to the Apps library

SPO admin view

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.