3

this is the error I am facing in here

public boolean validateToken(String jwt){

    Jwts.parser().setSigningKey(key).parseClaimsJws(jwt);

    return true;

}
Md Esadulhaq
  • 51
  • 1
  • 2

2 Answers2

11

Take a look at this documentation. You might want to do something like this.

Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(jwt);
Charles
  • 251
  • 4
  • 12
4

Charles answer solves one problem, but there are two deprecated methods here: parser() and setSigningKey(). In order to avoid both deprecations, the following code is required:

SecretKey secret = Keys.hmacShaKeyFor(Decoders.BASE64.decode(key));
Jwts.parserBuilder().setSigningKey(secret).build().parseClaimsJws(jwt);

You can read more about this at https://github.com/jwtk/jjwt#jws-create-key