Facebook OAuth突然停止工作 [英] Facebook OAuth stopped working suddenly

查看:102
本文介绍了Facebook OAuth突然停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我注意到我的网站Facebook登录已停止工作.

I noticed yesterday that my Facebook login for my website has stopped working.

在过去的两个月中,这一直非常有效,据我所知,我没有进行任何更改.我已经尽力在链接上进行了所有尝试,例如:-以及更多...

This has been working great for the last 2 months, as far as I am aware I have not changed anything. I have tried everything I can on links such as: - as well as many more...

ASP.NET MVC5 OWIN Facebook身份验证突然不起作用

我注意到Stack Overflow Facebook身份验证也已停止工作.

I have noticed that the Stack Overflow Facebook auth has also stopped working.

还有没有其他人注意到这一点并找到了解决方案?值得注意的是,我正在使用azure应用程序服务进行托管.但是当我使用本地主机时,也会发现此问题.

Has anyone else noticed this and found any solution? It's worth noting I am using azure app services to host. But this issue is also found when I am using localhost.

我当前的设置如下:

在Startup.Auth.cs中

in Startup.Auth.cs

var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions()
{
    AppId = "xxxxxxxxxxxxx",
    AppSecret = "xxxxxxxxxxxx"
};
facebookOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookOptions);

在以下方法中,每次loginInfo都是null.

In the following method, loginInfo is null every time.

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

我还从另一个帖子建议中添加了一个会话"WAKEUP",fb auth之前一次失败,并且这次解决了该问题,但是它又回来了.

I also added a session "WAKEUP" from a different post suggestion, fb auth failed once before and this fixed the issue this time, but it has come back.

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string returnUrl)
{
    Session["WAKEUP"] = "NOW!";

    // Request a redirect to the external login provider
    return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
}

推荐答案

如RockSheep所述. Facebook删除了支持vor API v2.2.您需要更新OWIN nuget软件包.

As RockSheep explained. Facebook dropped the support vor API v2.2. You need to update your OWIN nuget packages.

您可以在github上找到问题(来自Katanaproject).

You can find the issue on github (from the Katanaproject).

确保在nuget管理器中激活预发行版,然后才能将nuget软件包更新为版本 v3.1.0-rc1 .但要注意:更新后,您需要仔细测试您的登录名(也许您也有其他身份验证提供程序,例如Microsoft或Google,也应该对其进行测试).

Ensure to activate pre releases in your nuget manager, than you are able to update the nuget packages to version v3.1.0-rc1. But beware: After the update, you need to test your login carefully (maybe you also have other authentication providers like Microsoft or Google, you should test them as well).

技术

Api将版本号更改为v2.8,并且API的返回值现在为JSON格式,并且不再在URI中转义. 旧" OWIN软件包无法处理此更改.

The Api changed the version number to v2.8 and the return value from the API is now in JSON-Format and no longer escaped in the URI. The 'old' OWIN packages can not handle this changes.

[Oauth访问令牌]格式-的响应格式 https://www.facebook.com/v2.3/oauth/access_token 当你回来时 交换代码以获取access_token现在返回有效的JSON而不是 被URL编码.此响应的新格式为{"access_token": {TOKEN},"token_type":{TYPE},"expires_in":{TIME}}.我们做这个 更新以符合RFC 6749的5.1节.

[Oauth Access Token] Format - The response format of https://www.facebook.com/v2.3/oauth/access_token returned when you exchange a code for an access_token now return valid JSON instead of being URL encoded. The new format of this response is {"access_token": {TOKEN}, "token_type":{TYPE}, "expires_in":{TIME}}. We made this update to be compliant with section 5.1 of RFC 6749.

您可以在GitHub上找到代码更改,以获取更多信息和更好的理解.

Here you can find the code-changes on GitHub for further informations and better understanding.

这篇关于Facebook OAuth突然停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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