Skip to content

JsonWebTokenError: invalid signature while verifying token using JWT

In this quick post, we will see how to fix JsonWebTokenError: invalid signature error when you are implementing JSON Web Token in node.js and Java.

Advertisements

I’m using node.js example. I give a plain text secret key and I verify the token using the following line.

jwt.verify(token, jwtKey);

This line would throw the error JsonWebTokenError: invalid signature when the key looks valid when you validate it in the JWT Debugging Tool. JWT would actually say Signature Verified.

Signature Verified with JWT Online Debugging tool.

I fixed this error by using the Base64 version of the secret key. Plain text just didn’t work for me.

const jwtKey = 'QHhpZGlvCg=='
Advertisements

You could try the same.

Fin.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.