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
I figured out what is wrong with the code, I passed in wrong params. Below is the correct query
You should not provide
client_secret
value. Try to not provideclient
parameters. Maybe you’re providing wronguri
, or not passing required parameters. It works if you would take a look again.