Facebook的弹出登录与Owin弹出、Facebook、Owin

2023-09-06 10:51:29 作者:时光吹老了好少年。

我使用MVC与Owin外部登录与Facebook。

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

Owin不打开Facebook的登录为popup.It页面重定向到Facebook。

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

我知道有一个选项可以让Facebook登录开放作为popup.We需要添加&放大器;对话框=弹出在URL

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

我没有这个选项与OWIN。

I don't have this option with OWIN.

有没有办法做到这一点?

Is there any way to do that?

推荐答案

我有同样的问题。阅读虽然源之后,我发现了一个解决办法:

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

基本上是:你需要继续前进,创造一个身份验证提供者为Facebook。因此,创建一个类继承自FacebookAuthenticationProvider。在这个类,覆盖了ApplyRedirect的方法。使它看起来是这样的:

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!