0

When using a direct link(bookmark) to a page in my provided app the "SPAppWebUrl" query string is missing and the SPContext.CreateAppOnlyClientContextForSPAppWeb() is null.

This happens after the current user has been authenticated in the "SharePointContextProvider.CheckRedirectionStatus" method:

 protected void Page_PreInit(object sender, EventArgs e)
    {
        switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
        {
            case RedirectionStatus.Ok:
                return;
            case RedirectionStatus.ShouldRedirect:
                Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
                break;
            case RedirectionStatus.CanNotRedirect:
                Response.Write("An error occurred while processing your request.");
                Response.End();
                break;
        }
    }

The original direct link to page has the query parameters "SPHostUrl" and "SPAppWebUrl" and is working fine if the user already have been authenticated.

The "SPAppWebUrl" parameter is empty and "AppOnlyAccessTokenForSPAppWeb" is null after the current user has been authenticated running when the "RedirectionStatus.ShouldRedirect": enter image description here

If the current user already has been authenticated in SP before accessing the page (RedirectionStatus.Ok), everything is working fine: enter image description here

In the AppManifest.xml i am using query strings: enter image description here

The {StandarsTokens} have the "SPAppWebUrl" query string.

I really appreciate if someone can help me!

2

My first guess is, have you specified redirect url while registering your app in appregnew.aspx page?

For more info check this link

Basically what is happening is when you use bookmark to navigate to your app, the context token has expired. So you need to redirect to sharepoint site first to re-authenticate.

Hope this helps.

  • Thank you for the answer. I have not used appregnew.aspx to registrate my app. I'm running the app with a ClientSigningCertificate and clientID, and was thinking this was enough to re-authenticate when doing development. I'll could try registrate with appregnew.aspx to se if it helps. – hognis Jun 18 '14 at 14:08
  • Yes please check once.. Are you using on prem sharepoint environment? – Garima Jun 18 '14 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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