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"
}
);
What did I do wrong?
I'm using the jsonwebtoken package. https://github.com/auth0/node-jsonwebtoken
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);
}
});
Here is the link of jwt.io where I entered your secret used and it's saying verified.