criso / fbgraph

NodeJs module to access the facebook graph api
http://criso.github.io/fbgraph/
1.09k stars 174 forks source link

Validate access token #121

Open RWOverdijk opened 7 years ago

RWOverdijk commented 7 years ago

Hello

I wish to validate, from my app, a user's acces token. I can do that using the debug_token endpoint in the graph api.

I can't figure out how to do that using library. Any pointers?

ffflabs commented 6 years ago

I use something in the likes of:

 const graph = require('fbgraph'),
  myApp = {
    FACEBOOK_APP_ID: 123456,
    FACEBOOK_APP_SECRET: 'asdfghjkl'
  },
  graph_options = {
    timeout: 36000,
    pool: {
      maxSockets: Infinity,
    },
    headers: {
      connection: 'keep-alive',
    }
  },
  user_access_token = 'mjNfsEUdvZCVs67DRld5rEAF1TPcuzfMQLzT251IjhwvZBEp7lMyeagd7ShKUezZCr0pdYghH4yZBLlbMjaGV';

 graph.setVersion("2.11")
 graph.setOptions(graph_options);
 graph.setAccessToken(`${myApp.FACEBOOK_APP_ID}|${myApp.FACEBOOK_APP_SECRET}`);
 graph.get(`/debug_token?input_token=${user_access_token}`, function (err, res) {
  console.log(res);
 });