【问题标题】:Is this code Oauth 2.0 compatible?此代码是否兼容 Oauth 2.0?
【发布时间】:2012-04-09 07:16:56
【问题描述】:

Facebook 宣布所有应用必须在 2011 年 10 月 1 日之前迁移到 OAuth 2.0

2011 年 10 月 1 日 OAuth 2.0 迁移 正如我们在 5 月宣布的那样,所有应用 必须迁移到 OAuth 2.0 进行身份验证并期望加密 访问令牌。旧版 SDK,包括旧版 JS SDK 和旧版 iOS SDK 将不再工作。

在此处阅读更多信息:https://developers.facebook.com/docs/oauth2-https-migration/

现在我对所有不同的流程和版本感到很困惑。我正在进行一个简单的身份验证,基本上看起来像这样(我剥离了非必要部分)

    ## setup ###

    $url = "https://graph.facebook.com/oauth/authorize?client_id=".$this->appid."&redirect_uri=".$myurl;
    header("Location: $url");
    exit();     

当用户返回时...

    ## authentication check ##

    $code = isset($_GET["code"]) ? $_GET["code"] : false;
    if(!$code) {
        // user has not authenticated yet, lets return false so setup redirects him to facebook
        return false;
    }
    $url = "https://graph.facebook.com/oauth/access_token?client_id=".$this->appid."&redirect_uri=";
    $redirecturl = urlencode($redirecturl);     
    $url .= $redirecturl;
    $url .= "&client_secret=".$this->secret;
    $url .= "&code=".$code;
    $data = $this->get_data($url); // fetches content over https

    parse_str($data,$data);
    $token = $data['access_token'];
    $data = $this->get_data('https://graph.facebook.com/me?access_token='.urlencode($token));
    $data = json_decode($data);

    $id = $data->id;

    if($id > 0) {

        // yeah authenticated!

    } else {
        // login failed
    }

这种方法是否可以强制迁移?

【问题讨论】:

  • oauth2 规范明确指出,客户端应如何向 TokenEndpoint 进行身份验证。更多它说响应应该是json。也就是说:部分不符合标准。

标签: facebook-graph-api oauth facebook oauth-2.0


【解决方案1】:

简短的回答......是......

【讨论】:

  • TokenEndpoint 实现不确认 OAUTH2 标准。在 URL 中使用 client_secret 获取不是标准要求的方式。此外,它违反了标准中仔细描述的安全逻辑。
  • 我能说什么。你是对的。我想我当时指的是一个未完成的标准。毕竟已经2年了……
猜你喜欢
  • 2018-06-21
  • 2016-05-08
  • 1970-01-01
  • 2023-03-16
  • 1970-01-01
  • 2020-10-07
  • 1970-01-01
  • 1970-01-01
  • 2019-06-19
相关资源
最近更新 更多