Question

I'm trying using facebook c# sdk 4.0 using framework 3.5 for a Iframe Canvas App, i've achieved so far to authorize the app with extended permissions, but i'm not sure if I'm following the right way, as all i've done is through mix match of different answers here. Following is my code so far

Parent Class

protected string requiredAppPermissions = "email,publish_stream";

public MyMaster()
{
    fbApp = new FacebookApp();

    authorizer = new CanvasAuthorizer(fbApp);
    authorizer.Perms = requiredAppPermissions;
}

protected FacebookApp fbApp;
protected CanvasAuthorizer authorizer;

public void CanvasRedirect(string url)
{
    Contract.Requires(url != null);

    var content = CanvasUrlBuilder.GetCanvasRedirectHtml(url);

    Response.ContentType = "text/html";
    Response.Write(content);
}

Inherited Page

protected override void PageLoadEvent(object sender, EventArgs e)
{
    if (!authorizer.IsAuthorized())
    {
        var authurl = authorizer.GetLoginUrl(new HttpRequestWrapper(Request));
        CanvasRedirect(authurl.ToString());
    }
}

The premissions dialog doesn't redirect me back to my Canvas Page i.e. apps.facebook.com/myapp instead it redirects me to Canvas URL i.e. mydomain.com/myapp. Any guesses ???

TIA

Nauman

Was it helpful?

Solution 2

Alright finally i got the answer to this, needed to add following handler to web.config

<add name="facebookredirect.axd" verb="*" path="facebookredirect.axd"
       type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" />

OTHER TIPS

Verify the following settings in the facebook app edit page:

Website tab:

  • Site url: http://apps.facebook.com/<something>

Facebook Integration tab:

Canvas

  • Canvas Page Url: http://apps.facebook.com/<something>
  • Canvas Callback Url: <your_domain>

By the way, I am not sure if the setting's name are correct since I see my UI in Spanish

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top