Facebook PopUp Login with Owin

2019-04-15 18:14发布

I'm using MVC with Owin external login with Facebook.

Owin doesn't open facebook login as popup.It redirects the page to facebook.

I know there is a option to make facebook login open as popup.We need to add the "&dialog=popup" in the URL.

I don't have this option with OWIN.

Is there any way to do that?

1条回答
劫难
2楼-- · 2019-04-15 18:44

I had the same problem. After reading though the source, I found a solution:

Basically: you need to go ahead and create an authentication provider for Facebook. So create a class that inherits from FacebookAuthenticationProvider. Within this class, override the "ApplyRedirect" method. Make it look something like:

public override void ApplyRedirect(FacebookApplyRedirectContext context)
{
    context.Response.Redirect(context.RedirectUri + "&display=popup");
}

Now simply wire this class up with your configuration, like so:

app.UseFacebookAuthentication(new FacebookAuthenticationOptions
{
    Provider = new **<the name of the class that you created>**()
    // the rest of your configuration such as app ID and secret
});

And that should be it!

查看更多
登录 后发表回答