[英]Express passport middleware not woriking with get request params
I'm building a webserver with node, express, jwt and passport. 我正在建立一个带有节点,快递,jwt和通行证的网络服务器。 But when I try to have a route with a get methode: 但是当我尝试使用get方法路由时:
app.get('/api/:key/lights', passport.authenticate("jwt", {session: false}), function(req, res) {
if (yubiAtHome) {
var sKey = req.params.key;
dbController.checkApiKey(sKey, function(err, bData) {
if (bData.status) {
hueController.getLights(function(err, jData) {
if (err) {
generateResponse(res, 'get Lights', null, err, 'lLights', 500);
} else {
generateResponse(res, 'get Lights', jData, null, 'lLights', 200);
}
});
} else {
generateResponse(res, 'api key not valid', bData, 'apikey invalid', 'lLights', 500);
}
});
} else {
generateResponse(res, 'yub not pressent', null, 'yub not pressent', 'lLights', 500);
}
});
But this route do not work for some reason, if I remove the passport.authenticate("jwt", {session: false})
or remove the params ( the ":key") it works, but otherwise it do not and returns a 401:Unauthorized. 但是,由于某些原因,如果我删除了passport.authenticate("jwt", {session: false})
或删除了它起作用的参数(“:key”),该路由将不起作用,但否则将不起作用并返回一个401:未经授权。 How can this be ? 怎么会这样 ?
EDIT 编辑
Try to remove the quotation marks from the header Authorization
. 尝试从标题Authorization
删除引号。
Im my test here, when I put the quotation marks, it doesn't work. 我在这里进行测试,当我加上引号时,它不起作用。
Ex: 例如:
Authorization rather than 'Authorization' 授权而不是“授权”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.