Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The request is invalid because the app secret is the same as the client token

My Facebook app was working fine yesterday, but today it does not work for getting access_token.

My code is:

$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'];

The error is:

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

How to solve this issue?

I also used curl, but the response is:

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)
    }
} 
like image 233
Rajan Avatar asked Feb 16 '23 22:02

Rajan


2 Answers

Make sure the client token is different from the app secret (Advanced > Security) and also make sure your application is a web app and not native.

like image 154
isyi Avatar answered Feb 24 '23 07:02

isyi


When you receive this error you need to:

1) Set native/desktop app to "No"

Screenshot of Facebook dialog

2) Reset the previous client token. Facebook Client Token reset

3) Put the newly generated token into your app

You can find both of these on the advanced page for your Facebook app's settings: https://developers.facebook.com/apps/[your_app_id]/settings/advanced/

like image 43
PaulMest Avatar answered Feb 24 '23 07:02

PaulMest