skip to Main Content

I am working with Facebook Graph API and I have followed the instruction on the official documentation page to obtain a Long-Lived Token using a previously extracted access token by running the below code

//Get long-lived access token
var longLiveToken = "https://graph.facebook.com/v8.0/oauth/" +
  req.authInfo + "?grant_type=fb_exchange_token&client_id=" + process.env.FACEBOOK_CLIENT_ID +
  "&client_secret=" + process.env.FACEBOOK_CLIENT_SECRET + "&fb_exchange_token=" + req.authInfo +
  "&redirect_uri=http://localhost:4000/";

https.get(longLiveToken, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    console.log(d);
  });

}).on('error', (e) => {
  console.error(e);
});

However I am getting the below error message

'www-authenticate': 'OAuth "Facebook Platform" "invalid_request" "client_secret should not be passed to /oauth

My query is in line with the official documentation, not sure why I am getting this error message or how to go about resolving it

2

Answers


  1. Chosen as BEST ANSWER

    I figured out what is wrong with the code, I passed in wrong params. Below is the correct query

    var longLiveToken = "https://graph.facebook.com/v8.0/oauth/" +
      "access_token" + "?grant_type=fb_exchange_token&client_id=" + process.env.FACEBOOK_CLIENT_ID +
      "&client_secret=" + process.env.FACEBOOK_CLIENT_SECRET + "&fb_exchange_token=" + req.authInfo;


  2. You should not provide client_secret value. Try to not provide client parameters. Maybe you’re providing wrong uri, or not passing required parameters. It works if you would take a look again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search