i found this: How to passing data in TwitterStrategy, PassportJS? which was very helpful but i think it's uses either an old version of passport or express, or both:
I get no errors with my below code but passport.authenticate('twitter') doesn't appear to get called. I know my TwitterStrategy works so i don't think it's that, it think maybe i need to do a res.send() somewhere so the ajax request receives success? any help would be appreciated! thanks in advance!
var states={};
router.get('/auth/twitter', function(req, res, next){
var reqId = 'req'+req.sessionID
states[reqId] = {
turkeyName : req.query.turkeyName,
charityName : req.query.charityName,
votes : req.query.votes
};
req.session.state = reqId
next();
}, function(req, res, next) {
passport.authenticate('twitter');
});
and this is what i'm doing on the client
var params = {
turkeyName: $('#turkeyNameInput').val(),
charityName: 'Stand up to Cancer',
votes: 1
};
var auth = $.ajax({
type: 'GET',
url: '/auth/twitter',
data: params,
dataType: 'text',
async: true
});
auth.success(function(data){
console.log('$ajax.auth -- success');
console.log(data);
});
auth.error(function(err){
console.log('$ajax.auth -- error');
console.log(err);
});