It took me some time to grasp the concepts behind the authorize flow, and overriding the authenticate handler. There are numerous threads about this in the node-oauth2-server project, as I'm sure you are aware. I think even if your example included this commented out, this might be helpful?
Something like this?
oauth.authorize(request, response, {
authenticateHandler: {
handle: function(req, res) {
if (req.body.userId) {
// return full user object if necessary, otherwise just the ID
return req.body.userId;
}
else {
// redirect to login form
}
}
}
})
.then(function(success) {
console.log("SUCCESS", success);
cb(false, success);
})
.catch(function(err) {
console.log("AUTH ERR", err);
cb(err);
})
Hello,
It took me some time to grasp the concepts behind the authorize flow, and overriding the authenticate handler. There are numerous threads about this in the node-oauth2-server project, as I'm sure you are aware. I think even if your example included this commented out, this might be helpful?
Something like this?