Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
share|improve this question
    
Tschareck, could you post what you did to solve this issue. I'm running into same issue deploying the same demo app and haven't found a fix yet. Thanks –  Dave Jorgensen Jan 8 '13 at 23:37
add comment

2 Answers

Here's how I fixed it in my case.

Uninstall the app, then in the Office 365 Admin Center, click apps then App Permissions. Delete any app permissions left behind for your app, and install the app again.

I think what was happening was that it was using the wrong set of permissions and sending the app an invalid token.

share|improve this answer
add comment

I'm assuming you have already found a way around this issue, but I resolved it by editing the permissions my App needed to the Host Web. Originally I was just leaving it blank, but setting those permissions explicitly in the manifest got it working.

share|improve this answer
    
this did it for me. I constantly am forgetting to request access to the web. Weird for me is that I was able to connect without the permission, then it magically stopped working. –  Tim Gabrhel Feb 6 '13 at 5:26
    
My comment doesn't stand entirely. This seems to be a caching issue perhaps. –  Tim Gabrhel Feb 6 '13 at 6:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.