简体   繁体   English

如何在服务器端(Node.js)以编程方式验证Facebook用户的访问令牌?

[英]How to verify a Facebook user's access token programmatically on the server-side (Node.js)?

I have an access token by a Facebook user, and I'd like to verify whether this access token is valid, ie whether it is known to Facebook, currently valid, and so on… 我有Facebook用户的访问令牌,我想验证这个访问令牌是否有效,即Facebook是否知道,当前是否有效,等等......

So far, I have taken a look at the various APIs of Facebook , and basically, what I need is a combination of the User functionality to get the user's details, but for a user identified by an access token (not his / her ID). 到目前为止,我已经看了Facebook的各种API ,基本上,我需要的是用户功能的组合,以获取用户的详细信息,但对于由访问令牌(而不是他/她的ID)标识的用户。

I suppose that somehow I need to deal with the access token API , but as I am completely new to developing Facebook applications, I'm not sure where to start. 我想我不得不以某种方式处理访问令牌API ,但由于我对开发Facebook应用程序完全陌生,我不知道从哪里开始。

Basically, I can not imagine that this should be a quite hard task. 基本上,我无法想象这应该是一项非常艰巨的任务。 Intuitively I'd expect something such as: 直觉我会期待如下:

GET http://graph.facebook.com/me?accessToken=$INSERT_TOKEN_HERE

Does anything like this exist? 有这样的事吗? If so, can you please point me in the right direction? 如果是这样,你能指出我正确的方向吗? Even a few hints on what to search for (terms, eg) might be helpful. 关于搜索内容(例如术语)的一些提示可能会有所帮助。

By the way, this request shell be sent from a server, not from the browser. 顺便说一下,这个请求shell是从服务器发送的,而不是从浏览器发送的。

I don't know whether it is important, but I am using Node.js for this. 我不知道它是否重要,但我正在使用Node.js。 Additionally, if there's a ready-made module which can abstract the REST calls away, this might also be helpful and interesting. 另外,如果有一个现成的模块可以抽象出REST调用,那么这也可能是有用的和有趣的。

Any ideas? 有任何想法吗?

You can retrieve the information related to a particular Access Token by issuing a GET request to the debug_token connection. 您可以通过向debug_token连接发出GET请求来检索与特定访问令牌相关的信息。 Something like: 就像是:

GET /debug_token?
     input_token={input-token}&
     access_token={access-token}

You can get more information about it in the Getting Info about Tokens and Debugging reference. 您可以在获取有关令牌和调试的参考信息获取有关它的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM