Thursday, 14 December 2017

Signing then immediately verifying JWT token throws "Invalid signature"

Hello boys and girls,I'm trying to use node-jwt to provide auth on my (embedded) webapp. Here's the problematic piece of code :function generateToken (ipAddr){ var token = jwt.sign(ipAddr,"mysupersecret"); jwt.verify(token, "mysupersecret", function(err, decoded) { console.log(err); console.log(decoded); }); return token; } Calling generateToken (ipAddr is defined BTW) will raise a "Invalid signature" error, which really puzzles me. Important piece of information : this worked yesterday, with strictly the same code. I'm guessing a lower layer is causing the problem, but a day of seaching left me with no answer. Does someone have any ideas ?Have a good day :-)

Submitted December 14, 2017 at 02:30PM by mickev

No comments:

Post a Comment