ASP.NET MVC 5(VS2013决赛):Facebook登录与OWIN失败(LOGININFO为null) [英] ASP.NET MVC 5 (VS2013 final): Facebook login with OWIN fails (loginInfo is null)

查看:542
本文介绍了ASP.NET MVC 5(VS2013决赛):Facebook登录与OWIN失败(LOGININFO为null)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装的是昨天发布的VS2013最后位,我试图让一个例子,其中的工作使我的外部Facebook登录。我的第一个问题:

I installed the VS2013 final bits that were released yesterday, and I'm trying to get an example working where I enable an external Facebook login. My first question:

在此控制器code(我没有碰,保持不变从样品模板):

In this controller code (which I did not touch and left as is from the sample template):

    //
    // GET: /Account/ExternalLoginCallback
    [AllowAnonymous]
    public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
    {
        var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
        if (loginInfo == null)
        {
            return RedirectToAction("Login");
        }

我设置就行了断点等待AuthenticationManager.GetExternalLoginInfoAsync()。在code返回(后我做我的Facebook登录)和LOGININFO为空。在用户界面,登录页面继续显示,没​​有任何变化。如何调试呢?我试图找到GetExternalLoginInfoAsync(里面的code),但根据此线索:

I set a breakpoint on the line await AuthenticationManager.GetExternalLoginInfoAsync(). The code returns (after I do my Facebook login), and "loginInfo" is null. In the UI, the login page continues to be displayed, with no change. How can I debug this? I was trying to find the code inside of GetExternalLoginInfoAsync() but according to this thread:

<一个href=\"http://stackoverflow.com/questions/18801120/where-is-microsoft-aspnet-identity-owin-authenticationmanager-in-asp-net-identit\">Where是Microsoft.AspNet.Identity.Owin.AuthenticationManager在Asp.Net身份RTM版本?

AuthenticationManager会现在已经没有了。 (这似乎不是为每以上的情况。)

AuthenticationManager is now gone. (This does not seem to be the case per above.)

我的第二个问题:是任何人能得到(除取消注释app.UseFacebookAuthentication和FB应用程序的详细信息填写)样品用Facebook登录的工作没有改变ASP.NET MVC5样品code? (你必须配置别名主机与Facebook,如localtest.me,并与IIS前preSS配置。)

My second question: Is anyone else able to get the sample working with Facebook login with no changes to the ASP.NET MVC5 sample code (other than uncommenting app.UseFacebookAuthentication and filling in your FB app details)? (You'll have to configure an alias host with Facebook, such as "localtest.me" and configure it with IIS express.)

感谢您的帮助...

-Ben

推荐答案

好吧,这是愚蠢的我。首先,我开始使用招调试,看到Facebook的被发回这样的:

Ok, this was silly of me. First off, I started debugging using Fiddler, and saw that Facebook was sending back this:

WWW验证:OAuth的Facebook平台,INVALID_REQUEST请求无效,因为该应用程序的秘密是相同的客户端令牌

WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "The request is invalid because the app secret is the same as the client token"

此消息是不准确的,但寻找它,我发现了另一个线程在用户指定的重置应用程序的秘密解决了这个问题。 (我没有让可能已涉及在长时间使用此应用的)。所以我把这些步骤,但仍然看到了这个问题。但在提琴手的消息改变了:

This message was inaccurate, but searching for it, I found another thread where a user specified that resetting the app secret solved the problem. (I hadn't used this app in a long time so that may have been related.) So I took those steps, but still saw the problem. But the message in Fiddler changed:

WWW验证:OAuth的Facebook平台,INVALID_REQUEST

WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "The request is invalid because the app is configured as a desktop app"

事实上,应用程序在Facebook的配置错误。我将其设置为一个web应用程序,现在完美的作品!希望这可以帮助别人,因为这是不明确的,直到发射了小提琴手。

Indeed, the app was misconfigured in Facebook. I set it to be a web app, and it works perfectly now! Hopefully this can help others, as this was not clear until firing up Fiddler.

这篇关于ASP.NET MVC 5(VS2013决赛):Facebook登录与OWIN失败(LOGININFO为null)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆