After a day of reading and tutorialing, it seems that the answer is much simpler than I thought.
There was one thing I had to change - and it seems I did not mention it in the question.
The route mapping to the callback.
Before, it was
app.get('/backend/widgets/:widgetId/login/linkedin/callback',controllers.widgetLogin.linkedInLoginCallback);
but it seems that if I simply add a middleware here
passport.authorize('linkedin')
so now it looks like this
app.get('/backend/widgets/:widgetId/login/linkedin/callback', passport.authorize('linkedin'), controllers.widgetLogin.linkedInLoginCallback);
I get all the information I need on req.account. So my callback is now
exports.linkedInLoginCallback = function( req, res ){
logger.info('linkedin login callback',req.account);
res.send(200,req.account);
};
So all the magic relies on the callback's middleware!
Alternatively, if the routing is not under your control, you could change your callback to the following:
exports.linkedInLoginCallback = function( req, res ){
passport.authorize('linkedin')(req, res, function(){
logger.info('linkedin login callback',req.account);
res.send(200,req.account);
});
};
Which is my drug of choice.. seems like a simple function and callback without middleware cr%$.