Created
July 24, 2016 15:34
-
-
Save miki2826/76653b715c85d39181f0a57143f7a35c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/auth/facebook', (req, res, next) => { | |
passport.authenticate('facebook', { | |
callbackURL: 'http://localhost:3000/auth/facebook/callback?' + | |
(req.query.redirect_uri ? '&redirect_uri=' + req.query.redirect_uri : '') + | |
(req.query.account_linking_token ? '&account_linking_token=' + req.query.account_linking_token : ''), | |
scope: ['public_profile', 'email', 'user_friends', 'user_likes'] | |
})(req, res, next); | |
}); | |
app.get('/auth/callback/facebook', (req, res, next) => { | |
passport.authenticate('facebook', { | |
callbackURL: 'http://localhost:3000/auth/facebook/callback?' + | |
(req.query.redirect_uri ? '&redirect_uri=' + req.query.redirect_uri : '') + | |
(req.query.account_linking_token ? '&account_linking_token=' + req.query.account_linking_token : ''), | |
scope: ['public_profile', 'email', 'user_friends', 'user_likes'] | |
})(req, res, next); | |
}, (req, res) => { | |
// Successful authentication - link the accounts and redirect. | |
botly.getPSID(req.query.account_linking_token, (err, body) => { | |
//You should handle errors | |
var PSID = body.recipient; | |
req.user.update({PSID: req.user}, (err, data) => { | |
//link done, let's redirect | |
res.redirect(req.query.redirect_uri + '&authorization_code=' + req.user.id); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello ? Can you offer some hints please ? :D
Been stuck on this I'm seeing this error in the console . Also I think there's something wrong with your routes or ?
because in app.get('/auth/facebook the callbackurl is /auth/facebook/callback but this route doesn't exist so maybe it was /auth/callback/facebook ?