如何使用NodeJS获取Facebook用户访问令牌 [英] How to get facebook user access token using NodeJS

查看:169
本文介绍了如何使用NodeJS获取Facebook用户访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用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.

推荐答案

一种简单的方法:

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆