I tried to encode the data with the secret key using the jsonwebtoken package in nodejs and getting the following error:
The code that I used to encode the data using the secret key and algorithm is mention below:
var data = {
sub: "1234567890",
name: "John Doe"
};
var secretKey = "secret123";
var algorithm = { algorithm: "RS384" };
getJWTToken(data, secretKey, algorithm);
let getJWTToken = function(data, secretKey, algorithm) {
console.log(token: jsonwebtoken.sign(data, secretKey, algorithm));
};
It seems the problem is the algorithm. When I use the algorithm HS256, HS384 and HS512 it's working fine but when I used the algorithm RS256,RS384 and RS512 I am getting this error.
Can anyone help me out how to solve this issue?
