Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, i.e. whether it is known to Facebook, currently valid, and so on…

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).

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.

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, e.g.) might be helpful.

By the way, this request shell be sent from a server, not from the browser.

I don't know whether it is important, but I am using Node.js for this. Additionally, if there's a ready-made module which can abstract the REST calls away, this might also be helpful and interesting.

Any ideas?

like image 777
Golo Roden Avatar asked Dec 11 '13 11:12

Golo Roden


1 Answers

You can retrieve the information related to a particular Access Token by issuing a GET request to the debug_token connection. 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.

like image 58
Rahil Arora Avatar answered Sep 28 '22 17:09

Rahil Arora