Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Get context token for SharePoint 2013 provider hosted app (on-premise) with web project hosted on azure

$
0
0

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:


var contextTokenString = 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:

var contextTokenUrl = 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?



Viewing all articles
Browse latest Browse all 25064

Trending Articles