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

%3CLINGO-SUB%20id%3D%22lingo-sub-3205888%22%20slang%3D%22en-US%22%3ES2SUnauthorized%20error%20while%20retrieving%20Microsoft%20365%20usage%20reports%20via%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3205888%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20been%20trying%20to%20get%20usage%20reports%20via%20Graph%20API%20using%20MSGraphClient%20in%20SPFx.%20I%20have%20added%20Reports.Read.All%20permissions%20in%20my%20package-solution.config%20file.%20I%20am%20getting%20the%20error%20%22S2SUnauthorized-Invalid%20permissions%22.%3C%2FP%3E%3CP%3EI%20have%20also%20granted%20limited%20administrative%20role%20to%20the%20user%20for%20accessing%20the%20reports%20data.%20I%20have%20granted%20admin%20consent%20by%20going%20to%20the%20Azure%20AD%20application%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3EAs%20per%20this%20article%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fuse-msgraph%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fuse-msgraph%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ethis%20is%20a%20known%20issue.%3C%2FP%3E%3CP%3ECan%20anyone%20please%20suggest%20an%20alternate%20way%20of%20exporting%20usage%20reports%20data%20programmatically%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3205888%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20Graph%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EReports%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3210163%22%20slang%3D%22en-US%22%3ERe%3A%20S2SUnauthorized%20error%20while%20retrieving%20Microsoft%20365%20usage%20reports%20via%20MS%20Graph%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3210163%22%20slang%3D%22en-US%22%3EHi%2C%20even%20I%20am%20encountering%20same%20issue%20error%2C%3CBR%20%2F%3E%3CBR%20%2F%3ETried%20with%20Security%20Reader%20role%20and%20Global%20Administartor%20role%20but%20still%20same%20error.%3CBR%20%2F%3E%3CBR%20%2F%3ECould%20anyone%20help%20us%20here%20please%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3EAbhishek%3C%2FLINGO-BODY%3E
Regular Visitor

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

 

As per this article https://docs.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?

2 Replies
Hi, even I am encountering same issue error,

Tried with Security Reader role and Global Administartor role but still same error.

Could anyone help us here please?

Thanks,
Abhishek
Why don't you use the Graph API endpoints directly?