[英]Facebook Graph API Long-Lived Token
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我正在使用 Facebook 图表 API 并且我已按照官方文档页面上的说明通过运行以下代码使用先前提取的访问令牌获取长期令牌
//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我的查询与官方文档一致,不知道为什么我会收到此错误消息或如何 go 解决它
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;
You should not provide client_secret
value.您不应提供
client_secret
值。 Try to not provide client
parameters.尽量不提供
client
参数。 Maybe you're providing wrong uri
, or not passing required parameters.也许您提供了错误的
uri
,或者没有传递必需的参数。 It works if you would take a look again.如果您再看一遍,它会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.