始终在jwt.io中获得无效签名 [英] Always getting invalid signature in jwt.io
本文介绍了始终在jwt.io中获得无效签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在jwt.io中输入生成的令牌时,总是会得到无效的签名 这是我制作令牌的代码
I always get invalid signature when I input the generated token in jwt.io Here is my code for making the token
const secret = 'secret';
const token = jwt.sign({
username: user.username,
userID: user._id
},
secret, {
expiresIn: "1hr"
}
);
我做错了什么?
我正在使用jsonwebtoken包. https://github.com/auth0/node-jsonwebtoken
I'm using the jsonwebtoken package. https://github.com/auth0/node-jsonwebtoken
推荐答案
如果您使用的是 jsonwebtoken lib,我尝试并能够创建令牌并进行验证.请查看代码,如果您仍然遇到问题,请在注释中告诉我.
If you are using jsonwebtoken lib, I tried and able to create the token and verify as well. Please have a look at the code and let me know in comments if you are still facing the issue.
var jwt = require('jsonwebtoken')
const secret = 'secret';
const token = jwt.sign({
username: "",
userID: 1
},
secret, {
expiresIn: "1hr"
},
function(err, token) {
if (err) {
console.log(err);
} else {
console.log(token);
}
});
这是jwt.io的链接,我在其中输入了您使用的秘密并表示已通过验证.
Here is the link of jwt.io where I entered your secret used and it's saying verified.
这篇关于始终在jwt.io中获得无效签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文