Asp.net mvc MVC 5 Facebook登录访问被拒绝

Asp.net mvc MVC 5 Facebook登录访问被拒绝,asp.net-mvc,asp.net-mvc-5,facebook-login,access-denied,Asp.net Mvc,Asp.net Mvc 5,Facebook Login,Access Denied,我正在尝试在我的网站(MVC5)上设置Facebook登录,但我有一个问题,似乎我已经有几天无法克服了 在本地主机上,一切都可以完美地工作,但当部署到测试环境或生产环境时,它就不起作用了。我不断地得到“”,我不明白为什么 我在facebook开发者帐户中配置了所有内容,应用程序显示为绿色 这是我代码的一部分: 在Startup.Auth中: var options = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOp

我正在尝试在我的网站(MVC5)上设置Facebook登录,但我有一个问题,似乎我已经有几天无法克服了

在本地主机上,一切都可以完美地工作,但当部署到测试环境或生产环境时,它就不起作用了。我不断地得到“”,我不明白为什么

我在facebook开发者帐户中配置了所有内容,应用程序显示为绿色

这是我代码的一部分:

在Startup.Auth中:

var options = new    Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions
            {
                AppId = "xxx",
                AppSecret = "xxx",
                CallbackPath = new PathString("/signin-facebook"),
                BackchannelHttpHandler = new   Services.FacebookBackChannelHandler(),
                UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email,first_name,last_name"
            };

            options.Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
            {
                OnAuthenticated = (context) =>
                {
                    context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
                    foreach (var claim in context.User)
                    {
                        var claimType = string.Format("urn:facebook:{0}", claim.Key);
                        string claimValue = claim.Value.ToString();
                        if (!context.Identity.HasClaim(claimType, claimValue))
                            context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, "XmlSchemaString", "Facebook"));

                    }
                    return System.Threading.Tasks.Task.FromResult(0);
                }
            };
            options.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie;
            options.Scope.Add("email");
            options.Scope.Add("public_profile");

            app.UseFacebookAuthentication(options);
在AccountController中:

public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

            if (loginInfo == null)
            {
                return RedirectToAction("Login");
            }
public异步任务ExternalLoginCallback(string returnUrl)
{
var loginInfo=await AuthenticationManager.GetExternalLoginInfoAsync();
if(loginInfo==null)
{
返回重定向操作(“登录”);
}
我没有主意了…所以如果有人能帮我,我会很感激的

谢谢!我遇到了同样的问题。 最终,我通过升级Microsoft.Owin.Security.Facebook(到3.1.0版;在默认的VS2015中,在撰写本文时嵌入了MVC项目3.0.1)解决了这个问题

在Package Manager控制台中运行此命令:

PM> Install-Package Microsoft.Owin.Security.Facebook
我遇到了同样的问题。 最终,我通过升级Microsoft.Owin.Security.Facebook(到3.1.0版;在默认的VS2015中,在撰写本文时嵌入了MVC项目3.0.1)解决了这个问题

在Package Manager控制台中运行此命令:

PM> Install-Package Microsoft.Owin.Security.Facebook

我有一个类似的问题。只要我没有设置提供者、CallbackPath、BackchannelHttpHandler和UserInformationEndpoint,它就会工作。但我仍然无法访问声明…我有一个类似的问题。只要我没有设置提供者、CallbackPath、BackchannelHttpHandler和UserInformationEndpoint,它就会工作。但我仍然无法访问索赔。。。