I have an on-premise SharePoint environment for which I'm developing a provider hosted app using visual studio. The web project is hosted an azure. The app project contains a custom ribbon button that goes to the web project. Here I want to get the context token but when trying the following code the context token remains null:
TokenHelper.GetContextTokenFromRequest(Request);
SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
I have also tried the following but here I get that it is an unsupported token:
TokenHelper.GetAppContextTokenRequestUrl(hostWeb, Server.UrlEncode(Request.Url.ToString()));
SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenUrl, Request.Url.Authority);
I figure that i get the unsupported token error is because contextTokenUrl contains an url and not an actual token.
How can I get the context token for a SharePoint 2013 on-premise environment with an app and the web project hosted on Azure?