I'm creating my first app for SharePoint 2013. I follow this MSDN article, that explains how to create autohosted app.
This piece of code I took from the article and didn't change anything in it.
protected void Page_Load(object sender, EventArgs e)
{
TokenHelper.TrustAllCertificates();
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
if (contextTokenString != null)
{
// Get context token
contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
// Get access token
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
// Pass the access token to the button event handler.
Button1.CommandArgument = accessToken;
}
}
However, when I run my deployed app, I get SecurityTokenException: Invalid issuer or signature.
Any advice how to solve this error would be appreciated.
[SecurityTokenException: Invalid issuer or signature.]
Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.VerifySignature(String signingInput, String signature, String algorithm, SecurityToken signingToken) +873
Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadTokenCore(String token, Boolean isActorToken) +498
Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadToken(String token) +7
SharePoint_AutohostedApp1Web.TokenHelper.ReadAndValidateContextToken(String contextTokenString, String appHostName) in c:\Users\tsch\Documents\Visual Studio 2012\Projects\SharePoint-AutohostedApp1\SharePoint-AutohostedApp1Web\TokenHelper.cs:75
SharePoint_AutohostedApp1Web.Pages.Default.Page_Load(Object sender, EventArgs e) in c:\Users\tsch\Documents\Visual Studio 2012\Projects\SharePoint-AutohostedApp1\SharePoint-AutohostedApp1Web\Pages\Default.aspx.cs:24
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772