C # authorization issue for Facebook

I have an iFrame Facebook app. I use the Facebook C # SDK libraries, Facebookand Facebook.Web.

When a user first comes to my application, I create an object FacebookAppon page_load(). If the value app.Sessionis null, I create a CavasAuthorizer(app), then call Authorize().

Two problems:

Firstly, the redirect URL created during the call Authorizecauses a Facebook error with the wrong β€œnext” parameter. Says that the "next" parameter does not belong to the application. It looks like this:

next=http://localhost:4002/facebookredirect.axd/mygame_dev/mygame.aspx

I can edit the code in CanvasURLBuilderso that the following looks like this:

next=http://localhost:4002/mygame.aspx

At this point, the URL works if I cut and paste it into the browser, but it leads me to the second problem.

When the code is launched, the user is provided with a predominantly blank page with a medium-sized Facebook image and the link "go to Facebook". When the user clicks on the link, the user navigates to the correct login page for my application.

I have a feeling that these are two related problems, but potentially separate.

Any help here would be greatly appreciated.

-Andy

+3
source share
3 answers

For the first task

, URL- http://apps.facebook.com/ [your_app]/

alt text

.

, URL- , iframe, iframe, Facebook facebook. window.top.location = ... .

Facebook # SDK Mvc SDK. -, , .

protected void Page_Load(object sender, EventArgs e)
{
    var fb = new FacebookApp();
    var auth = new CanvasAuthorizer(fb);

    if (!auth.IsAuthorized())
    {
        var url = auth.GetLoginUrl(new HttpRequestWrapper(Request));

        var content = CanvasUrlBuilder.GetCanvasRedirectHtml(url);
        Response.ContentType = "text/html";
        Response.Write(content);
        Response.End();
        return;
    }

    //...Go on if authorized
}
+2

, , URL- URL facebook - - http://localhost:8181/yourpage. , VS \Web, , 8181 ( , , FB).

0

, URL- - localhost. , Facebook IFrame. - localhost - facebook. URL- web.config. , ip, , DNS. No-ip - ( ).

-1

Source: https://habr.com/ru/post/1776588/


All Articles