Hi,
I have a SharePoint 2013 Provider Hosted App with MVC Web application. I have added TokenHelper.cs to for CSOM.
But I am not getting client context, my code is as below:
var contextToken = TokenHelper.GetContextTokenFromRequest(Request); var hostWeb = Request["SPHostUrl"]; using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority)) { clientContext.Load(clientContext.Web, web => web.Title); clientContext.ExecuteQuery(); ViewBag.Message = clientContext.Web.Title; }
And I am getting error at following line in TokenHelper.c
SecurityToken securityToken = tokenHandler.ReadToken(contextTokenString);
This is because clientcontext is null.
Can anyone help me with it.
Thanks.