Forum Discussion
OfficeDevPnP.Core AuthenticationManager GetAppOnlyAuthenticatedContext is throwing error
I am thinking of trying OfficeDevPnp Core dll for CSOM operations in my current project. I'm doing a POC to check if add-in only context works for SharePoint 2013 on-premises. I have checked "GetNetworkCredentialAuthenticatedContext" method and it worked. But the method that gets add-in only context is not working and it throws error that object reference set to null. I want to understand if this method works for On-Premises. Got this doubt because it expects appsecret as a parameter and as I know appsecret (Client Secret) is not necessary for High Trust add-ins. I have registered an add-in from appregnew.aspx. And provided it Add-in only permissions. But my console job where I get the add-in only context fails. can someone let me know what could be wrong here?
- Ivan VaguninBrass Contributor
Hi,
Add-in authentication works for SharePoint 2013 in both "add-in only" and "add-in+user" types. If you want to setup High Trust add-in you don't need client secret (it is used for Low Trust scenario). To setup high trust add-in you need to create X.509 certificate, add it as trusted root authority and trusted security token issuer to SharePoint farm. Also if you need add-in only context, make sure that issuer id and client id for your add-in are the same.
More details here: https://msdn.microsoft.com/en-us/library/office/fp179901.aspx
- Christopher JohnsonBrass Contributor
Can you post the stack trace for the error?