Forum Discussion

Mathieu Marchant's avatar
Mathieu Marchant
Copper Contributor
Jun 25, 2019

AuthenticationManager.GetAppOnlyAuthenticatedContext Azure App API permissions access denied

 

When building a ClientContext based on an App ID and ClientSecret, you get an access denied  while trying to access a SharePoint site. I have tried setting several API permissions, separately for SharePoint or Microsoft Graph, but the behavior stays the same.

 

var authManager = new AuthenticationManager();

using (var clientContext = authManager.GetAppOnlyAuthenticatedContext(siteUrl, _sharePointSettings.AppId, _sharePointSettings.AppSecret))
{
     clientContext.Load(clientContext.Web);
     clientContext.ExecuteQuery();
}

 

Resources