S2SUnauthorized error while retrieving Microsoft 365 usage reports via MS Graph API

Sunny Rajpal 1 Reputation point
2022-02-23T18:38:38.583+00:00

I have been trying to get usage reports via Graph API using MSGraphClient in SPFx. I have added Reports.Read.All permissions in my package-solution.config file. I am getting the error "S2SUnauthorized-Invalid permissions".

I have also granted limited administrative role to the user for accessing the reports data. I have granted admin consent by going to the Azure AD application
177312-image.png

As per this article https://learn.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph this is a known issue.

Can anyone please suggest an alternate way of exporting usage reports data programmatically?

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
    2022-02-25T11:27:45.493+00:00

    Hi ,
    Could you please follow docs - reportroot-authorization , let me know if that helps.

    0 comments No comments

  2. CarlZhao-MSFT 46,371 Reputation points
    2022-02-28T02:55:38.27+00:00

    Hi @Sunny Rajpal

    You should not remove permissions, the permissions in Other permissions granted for Nagarro are all removed permissions, it will not appear in your token, you should add them to Configured permissions.

    178303-image.png

    Since the use of the implicit flow is in the browser, its length may be truncated, so the official does not recommend that you use the implicit flow to connect to the graph. I suggest you use auth code flow or client credential flow, they both work.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Aravind G 1 Reputation point
    2022-08-29T17:01:53.55+00:00

    Even am having the same issue.Also i have provided sharepoint administrator role to the user as it is required to provide limited administrator role in azure AD as per doc.

    https://learn.microsoft.com/en-us/graph/reportroot-authorization

    Could someone help on this please?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.