Cannot use passport-facebook-token in Nodejs (object is not a function)!

382 views Asked by At

I'm trying to implement an api for my android app which uses FB for authentication. I'm trying to use passport-facebook-token but I get this error when I make a new FacebookTokenStrategy:

passport.use('facebook-token', ^new FacebookTokenStrategy({ TypeError: object is not a function

here is my code:

var passport = require('passport');
var FacebookTokenStrategy= require('passport-facebook-token');
passport.use('facebook-token',new FacebookTokenStrategy({
clientID: "xxxxxxxxxx",
clientSecret: "xxxxxxxxxxxxxxxxxxxx"
},
function(accessToken, refreshToken, profile, done) {
users.findOrCreate({ facebookId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
1

There are 1 answers

1
Hirad Roshandel On BEST ANSWER

I had to change:

require('passport-facebook-token')

to:

require('passport-facebook-token').Strategy