Skip to content

"JsonWebTokenError: invalid signature" when verifying JWT signed with Java JWT #208

@nodje

Description

@nodje

I use https://github.com/jwtk/jjwt to encode and sign a token as follow:

 Jwts.builder() .setSubject(authentication.getName()) .claim(AUTHORITIES_KEY, authorities) .signWith(SignatureAlgorithm.HS512, "my-secret-token-to-change-in-production") .setExpiration(validity) .compact(); 

then decode in node.js as follow:

var decoded = jwt.verify(req.get('Authorization'), 'my-secret-token-to-change-in-production', { algorithms: ['HS512'] }); 

and get the error:

JsonWebTokenError: invalid signature 

Using jwt.decode I get the token content without problem.

Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions