Вопрос

I'm building a simple FB application but I'm getting a weird error. I have two pages: Default.aspx and Test.aspx. In Default.aspx I have the following:

var auth = new CanvasAuthorizer
{
    Permissions = new[] { "user_about_me", "email" },
    CancelUrlPath = "xxxxxxxxxxxxxxx",
    ReturnUrlPath = "xxxxxxxxxxxxxx"
};

if (!FacebookWebContext.Current.IsAuthorized())
{
    LitMsg.Text = "You must give permissions to this application";
}
else
{
    if (auth.Authorize())
    {
         // Token
         LitToken.Text = FacebookWebContext.Current.AccessToken;
    }
}

And then a button to navigate to the second page:

protected void LbStart_Click(object sender, EventArgs e)
{
    Response.Redirect("Test.aspx");
}

On the first page everything works. If the user never allowed the application to have access to those permissions, he'll be shown the permissions dialog box. The problem is in the second page. I was expecting to have access to the access token in the FacebookWebContext but this:

FacebookWebContext.Current.AccessToken

is empty when I land on the second page.

Why is that? How do I have access to the access token after I navigate to the second page?

Thanks in advance!

Это было полезно?

Решение

anchor tag is easier to navigate. and also make sure to use the target="_top"

<a href="http://apps.facebook.com/a/test.aspx" target="_top" />

Navigation needs to be in the outer most top iframe. If you still do want to use button, make sure to pass the value of signed_request manually. Refer to Problem when posting back to mvc 3.0 facebook app if u want to know how to pass the signed request.

If u navigate even after putting signed request, you still loose features like the url being the same which is bad for bookmarking. so preferred way is to use anchor tags.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top