passport-facebook-token icon indicating copy to clipboard operation
passport-facebook-token copied to clipboard

isAuthenticated() is always returning false

Open AkibShahjahan opened this issue 9 years ago • 1 comments

How would I use middleware to create a restful api authentication using token? Does anyone have a working example using passport-facebook-token? I just want to see an example where the passport-facebook-token is used to create a restful API with authentication and middlewares. req.isAuthenticated() is always giving me false.

This is the code i have

var passport = require('passport');
var FacebookTokenStrategy = require('passport-facebook-token').Strategy;
var mongoose = require('mongoose');

passport.use(new FacebookTokenStrategy({
        clientID: 'APP_ID_GOES_HERE',
        clientSecret: 'APP_SECRET_GOES_HERE',
    }, function(accessToken, refreshToken, profile, done) {
        console.log(profile);
                    // Do stuff with the profile. You're already getting authenticated data so there's no need to double check anything! For example
                    mongoose.model('User').findOrCreate({...}, function(err, user) {
                          done(err, user);
                    })
    })
);

   app.post('/login/facebook', passport.authenticate('facebook-token', {session: false}), function(req, res) {
    // Congratulations, you're authenticated!
    return res.json({status: 'OK'});
});

Thanks

AkibShahjahan avatar May 10 '16 12:05 AkibShahjahan

Perhaps, this will help? I am going through the same problem, I dont have time to test it right now though.

https://github.com/drudge/passport-facebook-token/issues/58

torch2424 avatar Oct 20 '16 00:10 torch2424