criso / fbgraph

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

Extending static access token #91

Open milosgacanovic opened 8 years ago

milosgacanovic commented 8 years ago

When i try to extend static access token using this code:

FBGraph.extendAccessToken({ "client_id": conf.client_id , "client_secret": conf.client_secret }, function (err, facebookRes) { console.log(facebookRes); });

i get an error :

{ error: { message: 'No user access token specified', type: 'OAuthException', code: 1, fbtrace_id: 'HVYelcFepXD' } }

I've tried also specifying

"access_token": client_access_token

which i get using this code:

FBGraph.authorize({ "client_id": conf.client_id , "client_secret": conf.client_secret , "grant_type": "client_credentials" }, function (err, facebookRes) { FBGraph.setAccessToken(facebookRes.access_token); client_access_token = facebookRes.access_token; });

Everything else works....

ffflabs commented 6 years ago

I use something like:

// current_token is the current user token I want to extend
graph.setAccessToken(current_token);

graph.extendAccessToken({
        client_id: myApp.FACEBOOK_APP_ID,
        client_secret: myApp.FACEBOOK_APP_SECRET,
        access_token: current_token
      },function(err, res) {
        console.log(res.access_token) // this is the renewed access token 
     });

(probably the first setAccessToken is not needed, I can't try it now)