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-........"
}
Error
System.Net.WebException: 'The remote server returned an error: (401) Unauthorized.'