Hi,
I'm creating a high-trust provider hosted app for SharePoint and have created a custom list instance on the app web. However when I try to load the list title from my code behind in the remote web application I get HTTP 401 Unauthorized. Any ideas why this issue occurs?
There's no problem accessing lists on the host web, so the issue is isolated to lists on the app web.
My sample code in the code behind is as follows:
protected override void Render(HtmlTextWriter writer) { base.Render(writer); TokenHelper.TrustAllCertificates(); Uri hostWeb = new Uri(Request.QueryString["SPAppWebUrl"]); using (var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(hostWeb, Request.LogonUserIdentity)) { Web web = clientContext.Web; clientContext.Load(web.Lists); clientContext.ExecuteQuery(); CamlQuery query = CamlQuery.CreateAllItemsQuery(); foreach (List list in web.Lists) { writer.Write(string.Format("<h1>{0}</h1>", list.Title)); writer.Write("<hr/>"); }