本文介绍了版本弃用Facebook Graph API v2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Facebook登录现在不起作用。我们收到了Facebook开发人员门户的消息:

our Facebook Login is not working right now. We have received a message from Facebook Developer Portal:

要检查您的应用程序是否会受到此升级的影响,您可以使用
版本升级工具。这将显示哪些电话(如果有)是
受此更改影响,以及任何更新的更新的
版本。如果您没有看到任何电话,您的应用程序可能不会受到此更改
的影响。

To check if your app will be affected by this upgrade you can use the Version Upgrade Tool. This will show you which calls, if any, are affected by this change as well as any replacement calls in newer versions. If you do not see any calls, your app may not be affected by this change.

您还可以使用我们的更改日志查看完整的更改列表在
Graph API版本中。

You can also use our changelog to see the full list of changes in all Graph API versions.

我们正在使用ASP.NET MVC 5,我们正在使用或认证:

We are using ASP.NET MVC 5, and we are using or authentication like this:

var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
            {
                AppId = "****",
                AppSecret = "****",
                AuthenticationType = "Facebook",
                SignInAsAuthenticationType = "ExternalCookie",
                Provider = new FacebookAuthenticationProvider
                {
                    OnAuthenticated = async ctx => ctx.Identity.AddClaim(new Claim(ClaimTypes.Email, ctx.User["email"].ToString()))
                }
            };

            facebookAuthenticationOptions.Scope.Add("email");

但是今天,我们的登录信息对象在ExternalLoginCallback中为null:

But today, our login info object, is null in ExternalLoginCallback:

        [HttpGet]
        [AllowAnonymous]
        [RequireHttps]
        public async Task<ActionResult> ExternalLoginCallback(string returnUrl = null)
        {
            try
            {
                var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (loginInfo == null)
                {
                    return RedirectToAction("Login");
                }
... more code here...

在Facebook开发。 Portal我们的API版本是2.3

In Facebook Dev. Portal our API Version is 2.3

我们测试了许多选项,没有结果:

We have tested many options, with no results:

为什么新的fb api 2.4在MVC 5上使用Identity和oauth 2返回null电子邮件? >

Why new fb api 2.4 returns null email on MVC 5 with Identity and oauth 2?

非常感谢您的帮助。

推荐答案

同样的问题,这里是我如何设法解决它,并从Facebook获取电子邮件。

I had the same problem and here is how I managed to fix it and get the email from Facebook.