Closed Exegetech closed 9 years ago
Sorry, figured it out, I need to modify my route to be
router
.get('/', passport.authenticate('linkedin', {
failureRedirect: '/signup',
scope: ['r_fullprofile', 'r_emailaddress', 'r_contactinfo'],
session: false
}))
.get('/callback', passport.authenticate('linkedin', {
failureRedirect: '/signup',
session: false
}), auth.setTokenCookie);
Anyone care to explain why?
@christiansakai thanks for documenting this. From the passport.authenticate docs:
After successful authentication, Passport will establish a persistent login session. This is useful for the common scenario of users accessing a web application via a browser. However, in some cases, session support is not necessary. For example, API servers typically require credentials to be supplied with each request.
angular-fullstack
uses JWT for authentication so passport does not need to establish the session as that is taken care of by auth.setTokenCookie
.
/**
* Set token cookie directly for oAuth strategies
*/
function setTokenCookie(req, res) {
if (!req.user) return res.json(404, { message: 'Something went wrong, please try again.'});
var token = signToken(req.user._id, req.user.role);
res.cookie('token', JSON.stringify(token));
res.redirect('/');
}
Therefore session: false
tells passport to skip/ignore session establisment AND verification.
Does that help out?
Thank you, yes it definitely clear things out. Sorry I forgot to close the issue.
Hello, I was trying to incorporate linkedin Oauth 1.0. Unfortunately, I didn't scaffold the app with the option of Twitter Oauth (which is also 1.0). I however, tried to see what the codes were for Twitter Oauth 1.0 by scaffolding another app with Twitter Oauth.
As far as I follow, I have all the codes necessary.
but I keep getting this error,