如何使用NodeJS获取Facebook用户访问令牌 [英] How to get facebook user access token using NodeJS
问题描述
如何使用NodeJS获取用户访问令牌?我尝试了多种方法,但无法使用其中任何一种方法
How can I get a user access token using NodeJS ? I have tried mulitple approaches and I can't it to work using any of them
我尝试了 facebook-node-sdk ,但是似乎确实需要访问权限-预先标记. 我也尝试过 facebook-passport ,但我需要从后端获取之后再调用Facebook API
I tried facebook-node-sdk but, it seems it does require to have access-token beforehand. I also tried facebook-passport but I need to get that from backend to call Facebook APIs after that
修改
我尝试进行登录,然后自动发布帖子,我没有用谁来批准Facebook弹出窗口.
am trying to do the login, and after that publishing posts automatically, I don't have a use who will approve on the facebook popup.
推荐答案
一种简单的方法:
- 使用JavaScript SDK: https://developers.facebook.com/docs/javascript/
- 使用
FB.login
获取用户令牌后,将令牌通过AJAX传输到服务器,并在服务器上使用-通过某些SDK或axios/fetch/随便什么.
- Use the JavaScript SDK: https://developers.facebook.com/docs/javascript/
- After getting a User Token with
FB.login
, transfer the Token to the server with AJAX and use it on the server - either with some SDK, or with axios/fetch/whatever.
Alternatively, you can build your own login flow: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/
这篇关于如何使用NodeJS获取Facebook用户访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!