I created a new app by following this tutorial
I was able to press F5 and it showed me the Do you Trust it screen, and I installed.
Code is like this:
public ActionResult Index()
{
Uri hostWeb = new Uri(Request.QueryString["SPHostUrl"]);
using (
var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(hostWeb,
Request.LogonUserIdentity))
{
var web = clientContext.Web;
clientContext.Load(web, w=>w.Lists.Include(l=>l.Title).Where(l=>!l.Hidden));
clientContext.ExecuteQuery();
return View(web.Lists);
}
}
I checked the HOST WEB and my username is on the Owners group. I debuggeed and Request.LogonUnserIdentity is showing my username, so that means the app is being executed under my identity which is ok
Whats happening then?
I noticed that when do F5, the url in ths browser is with localhost I had to replace it because this site wont let me put localhost, looool!
I found this on my ULS Logs
SPApplicationAuthenticationModule: Error authenticating request, Error details: Header: 3000006;reason="Token contains invalid signature.";category="invalid_client", Body: {"error_description":"Invalid JWT token. Could not resolve issuer token."}