Answer the question
In order to leave comments, you need to log in
How to change http headers in node js using passport.js and express?
In my api, authorization occurs when accessing / oauth / token
whereapp.use('/oauth/token', oauth2.token);
oauth2.token = [
passport.authenticate(['basic', 'oauth2-client-password'], { session: false }),
aserver.token(),
aserver.errorHandler()
];
app.get('/api/someMethod', function (req, res)
{
sendCors(res, req);
...
});
app.use('/oauth/token', function (req, res)
{
sendCors(res, req);
oauth2.token[0]();
oauth2.token[1]();
oauth2.token[2]();
});
Answer the question
In order to leave comments, you need to log in
Solved by installing a custom callback:
router.route('/login/')
.post(function(req, res, next){
passport.authenticate('digest', function(err, user, info){
if(err) return console.log(err);
if(!user){
res.set('WWW-Authenticate', 'x'+info);
return res.send(401);
}
req.login(user, function(err){
if(err) return console.log(err);
res.redirect('/admin/');
});
})(req, res, next);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question