criso / fbgraph

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

Extend Access Token (Due to deprecation of offline_access scope) #17

Closed jwchang0206 closed 11 years ago

jwchang0206 commented 11 years ago
graph = require("fbgraph");

extendAccessToken = function (accessToken, callback) {
    var uri = "oauth/access_token?client_id=" + process.env.FACEBOOK_APP_ID + "&client_secret=" + process.env.FACEBOOK_APP_SECRET + "&grant_type=fb_exchange_token&fb_exchange_token=" + accessToken;
    graph.get(uri, function (err, res) {
      process.nextTick(function () {
        typeof callback === "function" ? callback(res.access_token) : void 0;
      });
    });
}

Consider adding this on fbgraph :)

michikono commented 11 years ago

Documentation mentions this, but it's not actually in the released code!

michikono commented 11 years ago

Also, the documented method for called extendAccessToken doesn't have a callback, but the code in master clearly requires it to have one. The OP's version of the code checks that the callback is a function, but the one on master does not and will crash if you run the sample code found on the home page.

criso commented 11 years ago

Thanks for pointing this out!

This got done on: https://github.com/criso/fbgraph/pull/28