我正在尝试将令牌传递给res.redirect
上的回调,但是我得到了
无法获取/ api / users / auth / github / 200
我也需要它重定向。
router.get('/auth/github', passport.authenticate('github', { session: true, scope: ['profile'] }) );
router.get('/auth/github/callback',
passport.authenticate('github', { failureRedirect: '/' }),
function(req, res) {
// Successful authentication, redirect home.
var token = jwt.sign({ id: req.user.id}, 'nodeauthsecret');
res.cookie("jwt", token, { expires: new Date(Date.now() + 10*1000*60*60*24)});
// res.status(200).send({ authenticated: true});
// res.status(200).send({
// message: 'user signed in',
// token:token
// });
res.redirect(200, 'http://127.0.0.1:8001/dashboard', {message:'user signed in', token: token});
console.log(token)
console.log('this works');
});