Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect Local Users to Facebook/Twitter with PassortJS
    primarykey
    data
    text
    <p>I have an existing user base, that I want to allow them to link with their Facebook/Twitter Accounts. Looks like I can use passportjs but am having difficulty,</p> <p>Right now, a url pass in their user/pass, I do a local stragety, and look up the user. Then I want to perform an authorize I presume. I get the facebook promopts asking if I want to allow, and I hit the callback with the accessToken, but I have no way to tie that token to an existing user in my db as I see now way to get the request info.</p> <pre><code>passport.serializeUser(function(user, done) { done(null, user); }); passport.deserializeUser(function(user, done) { Users.findOne({_id: user._id}, function(err, user) { return done(err, user); }); }); passport.use(new LocalStrategy({ passReqToCallback: true }, function(req, username, password, done) { Users.findOne({_id: username}, function(err, user) { return done(null, user); }); } )); passport.use(new FacebookStrategy({ clientID: 'xxxx', clientSecret: 'xxxx', callbackURL: "http://xxxx/facebook/callback", passReqToCallback: true }, function(req, accessToken, refreshToken, profile, done) { // How would I get access to the user found in the LocalStrategy here so I can associate the accessToken to the user in the db? console.log(accessToken); console.log(refreshToken); var err = null; var user = {}; return done(err, user); } )); server.get('/facebook', passport.authenticate('local', { failureRedirect: '/login', failureFlash: true }), function (req, res) { if (req &amp;&amp; req.user) { passport.authorize('facebook', { scope: ['publish_actions','manage_pages'] })(req, res); } }); server.get('/facebook/callback', passport.authorize('facebook', { failureRedirect: '/facebook/failure', successRedirect: '/facebook/success' }), function(req, res) { res.redirect('/'); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload