Ral*_*h N 1 asp.net-mvc facebook oauth-2.0 asp.net-core
我正在使用 ASP.NET MVC 6(.net 核心)。有了它,我正在使用内置的外部登录逻辑来对 Facebook 进行身份验证。
我对其进行了修改,以便不是在同一窗口中进行身份验证,而是启动一个弹出窗口并在那里进行身份验证。成功后,弹出窗口会自行关闭并告诉我的主窗口重定向。这一切都有效。
但是,我想使用 Facebook 登录页面的“较小/迷你”版本。这可以在这里看到:https : //www.facebook.com/login.php?display=popup
“display=popup”是控制它的东西。
我不知道如何在我的 C# 代码中注入这个 kvp。我在哪里可以做?
app.UseFacebookAuthentication(new FacebookOptions
{
// was hoping for something here... tried to stick it into the authorizationurl but then i end up with 2 question marks and it fails
AppId = "blah",
AppSecret = "blah"
});Run Code Online (Sandbox Code Playgroud)
[AllowAnonymous]
public IActionResult ExternalLogin(string provider, string returnUrl = null)
{
var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
// Don't see anything here...
return Challenge(properties, provider);
}Run Code Online (Sandbox Code Playgroud)
您可以使用OnRedirectToAuthorizationEndpoint事件:
var facebookOptions = new FacebookOptions
{
AppId = "",
AppSecret = "",
Events = new OAuthEvents()
{
OnRedirectToAuthorizationEndpoint = ctx =>
{
ctx.HttpContext.Response.Redirect(ctx.RedirectUri + "&display=popup&pip");
return Task.FromResult(0);
}
}
};
app.UseFacebookAuthentication(facebookOptions);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1251 次 |
| 最近记录: |