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'});
});
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
Thanks