简体   繁体   English

Facebook 图 API 长寿命令牌

[英]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.

相关问题 将短期访问令牌交换为长期有效 - Exchange short-lived access token for long-lived, not working 从 Instagram 基本显示 API 获取长期访问令牌的问题 - Troubles Fetching a Long-lived Access Token from the Instagram Basic Display API 使用Apache / PHP / Javascript的长期连接(异步服务器推送)? - Long-lived connections (asynchronous server push) with Apache/PHP/Javascript? Recoil:将长期存在的客户端 object 传递给选择器 - Recoil: Passing a long-lived client object to a selector 如何建立与jQuery的长期连接以进行推送通知? - How can I establish a long-lived connection with jQuery for push notification? chrome扩展中具有长期连接的“尝试使用断开连接的端口对象” - “Attempting to use a disconnected port object” with Long-lived connections in chrome extension 在 React Base chrome 扩展中使用长寿命连接时无法获取状态值 - Unable to get state value in when using long-lived connection in react base chrome extension JavaScript最佳实践:如何实现长期存在的应用程序(单页Web应用程序)? - JavaScript Best Practices: How to implement long-lived apps (one-page web apps)? Chrome扩展程序的长期消息连接-如何使用回调函数? - Chrome extension long-lived message connection - how to use callback functions? 如何在浏览器中获取JS代码的长期身份提供者令牌 - How to get long-lived indentity provider tokens for JS code in browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM