Get profile data in getVenmo controller
This commit is contained in:
2
app.js
2
app.js
@ -150,7 +150,7 @@ app.get('/auth/tumblr', passport.authorize('tumblr'));
|
|||||||
app.get('/auth/tumblr/callback', passport.authorize('tumblr', { failureRedirect: '/api' }), function(req, res) {
|
app.get('/auth/tumblr/callback', passport.authorize('tumblr', { failureRedirect: '/api' }), function(req, res) {
|
||||||
res.redirect('/api/tumblr');
|
res.redirect('/api/tumblr');
|
||||||
});
|
});
|
||||||
app.get('/auth/venmo', passport.authorize('venmo', { scope: 'access_profile make_payments' }));
|
app.get('/auth/venmo', passport.authorize('venmo', { scope: 'make_payments access_profile access_balance access_email access_phone' }));
|
||||||
app.get('/auth/venmo/callback', passport.authorize('venmo', { failureRedirect: '/api' }), function(req, res) {
|
app.get('/auth/venmo/callback', passport.authorize('venmo', { failureRedirect: '/api' }), function(req, res) {
|
||||||
console.log('Success');
|
console.log('Success');
|
||||||
res.redirect('/api/venmo');
|
res.redirect('/api/venmo');
|
||||||
|
@ -415,7 +415,15 @@ exports.postTwilio = function(req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.getVenmo = function(req, res, next) {
|
exports.getVenmo = function(req, res, next) {
|
||||||
res.render('api/venmo', {
|
var token = _.findWhere(req.user.tokens, { kind: 'venmo' });
|
||||||
title: 'Venmo API'
|
var query = querystring.stringify({ access_token: token.accessToken });
|
||||||
|
request.get({ url: 'https://api.venmo.com/v1/me?' + query, json: true }, function(err, request, body) {
|
||||||
|
if (err) return next(err);
|
||||||
|
res.render('api/venmo', {
|
||||||
|
title: 'Venmo API',
|
||||||
|
profile: body.data
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
Reference in New Issue
Block a user