Forum Discussion
AuthenticationManager.GetAppOnlyAuthenticatedContext Azure App API permissions access denied
- Jul 10, 2019If you're connecting to the SharePoint APIs using the Azure App registration you'll need to do it with a certificate as detailed here https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
Otherwise use the method in my other post
Mathieu Marchant Did you use this method to create the app id and secret - https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
If so what's the XML you used for the permissions?
- Mathieu MarchantJul 10, 2019Copper Contributor
Toby Statham I used the Azure Portal to register a new App under "Azure Active Directory" and from there I generated a new secret. Additionally I also added SharePoint related "API permissions" from there.
However I still get an access denied. So what I need to do, is lookup the app with the appinv.aspx from within SharePoint and add additional permissions from there with the xml.
What I would expect, is that setting the API permissions from the Azure Portal would be enough, but that doesn't seem to be the case. Is suppose by using the AuthenticationManager, the credentials are built up in a different way?
- Toby StathamJul 10, 2019Brass ContributorIf you're connecting to the SharePoint APIs using the Azure App registration you'll need to do it with a certificate as detailed here https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
Otherwise use the method in my other post- Rahul SuryawanshiJul 19, 2019Brass Contributor
Please make sure you granted appropriate API permission to Azure AD app for SharePoint. You can do it by going to Azure AD and then 'App Registration' and then 'API Permissions'. Under Microsoft APIs, select SharePoint and then provide either delegated or application permission based on your requirement.