I have faced JWT token generation error while implementing HMACSHA256.
But this method is nor reconized by Springboot JWT library. com.auth0:java-jwt:3.19.0
Below is the code snippent:
Long expTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(90);
String jwtHeader = “{“alg”: “HS256”,“typ”: “JWT”}”;
String jwtPayload = “{\n”
+ " “iss”: “XXXXXXXXXX”,\n"
+ " “exp”: “+expTime+”\n"
+ “}”;
System.out.println(“expTime”+ expTime);
String API_SECRET = “XXXXXXXXl”;
String token = “”;
try {
Algorithm algorithm = Algorithm.HMACSHA256(
base64UrlEncode(jwtHeader) + “.” +
base64UrlEncode(jwtPayload));
token = JWT.create()
.withIssuer(“iss”)
.sign(algorithm);
} catch (JWTCreationException exception){
//Invalid Signing configuration / Couldn’t convert Claims.
}
Kindly help regarding this
Thanks