When I run the app from Visual Studio, I get the page where I opt to trust the app. However, I get the 401 Unauthorized error when I try to access the app from the site.

Stack trace:
[WebException: The remote server returned an error: (401) Unauthorized.]
   System.Net.HttpWebRequest.GetResponse() +1788
   Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() +49
   Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +973
   DemoAppWeb.Pages.Default.Page_Load(Object sender, EventArgs e) +401
   System.Web.UI.Control.OnLoad(EventArgs e) +109
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498

I ran the Set-SPAppPrincipalPermission cmd also.

  • Did you register the app by going to /_layouts/15/appregnew.aspx? What is the line that throws the error? – wjervis May 13 '16 at 17:52
  • Check your client ID and client secret in your app web's web.config and make sure that you are using the one you generated in appregnew.aspx – Rajesh Sitaraman May 13 '16 at 18:17
  • Yes I registered in appregnew.aspx – software dev May 14 '16 at 3:16
  • I checked already my client ID,secret, and webconfig.. – software dev May 14 '16 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.