本文介绍了通过Passport.js Facebook策略进行身份验证后,如何使用Facebook Graph API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用Facebook策略对用户进行身份验证,并获得了他们的用户信息.我的应用程序现在需要访问Facebook上的其他图形api端点.我没有找到一种方法来访问向Facebook图形api发送请求的工具.进一步研究该策略后,我发现一切都是围绕OAuth 2策略构建的.

I've authenticated my user with the Facebook strategy and obtained their user info. My application now needs to hit other graph api endpoints on Facebook. I don't see a way to access a tool to send requests to the Facebook graph api. Upon inspecting the Strategy a little further, I see everything is built around the OAuth 2 strategy.

1)我如何使用Facebook策略调用其他图形api端点?

1) How do I use the facebook strategy to call other graph api endpoints?

2)我是否应该在某个地方钻探通行证api以便在某个地方访问相关的oauth对象以使这种情况发生?

2) Am I supposed to drill into the passport api somewhere to access a related oauth object somewhere to make this happen?

还是我在想这个错误,我应该获取用户的访问令牌并使用另一个第三方库来查询facebook api?

Or am I thinking about this wrong and I should be getting the user's access token and using another 3rd party library for querying the facebook api?

推荐答案

后一种,您只需要访问令牌,然后您就可以发送带有vanilla或您想要的每个lib的普通请求(我个人喜欢wreck ).

The latter one, you just need the access token and then you can just send a normal request with vanilla or every lib you'd like (I personally like wreck).

然后看起来像这样:

Wreck.get('https://graph.facebook.com/me?access_token=' + access_token, function(err, res, payload) { });

这篇关于通过Passport.js Facebook策略进行身份验证后,如何使用Facebook Graph API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 11:29