Forum Discussion
Nov 09, 2018
App Only Authenticated Context using client id and secret - SharePoint 2016
Hi,
I am trying to get App Only Authenticated Context using the below code in SharePoint 2016 but getting the following error:
The remote server returned an error: (401) Unauthorized
Microsoft article says this model works for both SharePoint Online and SharePoint 2013/2016 on-premises. Is that right?
string siteUrl = "https://sp2016vm:5555/sites/dev";
using (var cc = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, "[Client ID]", "[Client Secret]"))
{
cc.Load(cc.Web, p => p.Title);
cc.ExecuteQuery();
Response.Write(cc.Web.Title);
};
No RepliesBe the first to reply