请求无效,因为app secret与客户端令牌相同

时间:2013-04-04 12:58:41

标签: php facebook api facebook-graph-api

我的Facebook应用程序昨天运行正常,但今天它无法获取access_token。

我的代码是:

$token_url="https://graph.facebook.com/oauth/access_token?"."client_id=".$app_id."&redirect_uri=".urlencode($my_url)."&client_secret=".$app_secret."&code=".$code;
$response=file_get_contents($token_url);
print_r($response);
$params = null;
parse_str($response, $params);
echo  $params['access_token'];

错误是:

{
   "error": {
      "message": "The request is invalid because the app secret is the same as the client token",
      "type": "OAuthException",
      "code": 1
   }
}

如何解决这个问题?

我也使用curl,但响应是:

object(stdClass)#121 (1) {
    ["error"]=> object(stdClass)#11 (3) {
        ["message"]=> string(77) "The request is invalid because the app secret is the same as the client token"
        ["type"]=> string(14) "OAuthException"
        ["code"]=> int(1)
    }
} 

4 个答案:

答案 0 :(得分:7)

确保客户端令牌与应用程序密钥(高级>安全性)不同,并确保您的应用程序是Web应用程序而非本机应用程序。

答案 1 :(得分:1)

当您收到此错误时,您需要:

1)将原生/桌面应用设置为"否"

Screenshot of Facebook dialog

2)重置以前的客户端令牌。 Facebook Client Token reset

3)将新生成的令牌放入您的应用

您可以在Facebook应用的高级页面上找到这两个设置: https://developers.facebook.com/apps/[your_app_id]/settings/advanced/

答案 2 :(得分:0)

我重置app_secret然后正常工作,并将Advanced-> security更改为WEB

答案 3 :(得分:0)

我遇到了同样的问题,有几天,我搜索并搜索解决方案。但是当我设置"原生或桌面应用程序时,一切正常。到"不" - 在" app-> settings-> advanced"

相关问题