I am trying to access SharePoint tenant details and able to get an accessToken using Oauth2 flow.
then I used this token with CSOM to get tenant details as below.
but I get 401 error . is there any reason for this? .

using (var clientContext = new AuthenticationManager(accessTokenScureString)
         .GetContext("https://tenant-admin.sharepoint.com") )
              Tenant tenant = new Tenant(clientContext);
              var x = tenant.GetAppCatalog();

Decoded token which has AllSites.FullControl scope

          "scp": "AllSites.FullControl User.Read User.Read.All",               
          "sub": "NXPMNfjX2HEBjxSWBhSof.........",
          "tid": "23e45f37-1111-2222-a601-........"


System.Net.WebException: 'The remote server returned an error: (401) Unauthorized.'  
  • Did you check below soultion? Please mark as answer if you are satisfied Jan 21, 2022 at 11:30

1 Answer 1


In order to use CSOM Core with Sharepoint Online you will require Sites.FullControl.All. and User.Read.All.

Please refer the below microsoft docs for more details.

Grant Access Via Azure Ad

Please mark it as answer if solve you problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.