Skip to content
Advertisement

Why do I get a “io.jsonwebtoken.ExpiredJwtException”?

I have a problem with my Spring Security JWT Application. I am getting an error because my JWT is expired, but I can’t find, where it gets the 2022-04-12 as an expiration date. I can’t find a single piece of code, which says that the expiration date is the 2022-04-12. After my understanding, it is creating a new token, each time I am logging in with a new expiration time, which also has to be true, because in my output I get a new token everytime. But because the 2022-04-12 has already passed, I am getting a “io.jsonwebtoken.ExpiredJwtException”. So where does it get the 2022-04-12 from??? I am just providing the parts of my code, I think are neccesary, but if you need more code, just let me know!( I am using Spring Security, if that matters)

Filter:

JavaScript

Util class for JWT:

JavaScript

Rest Controller class:

JavaScript

Security Configurer class:

JavaScript

Here is the error log:

JavaScript

This is the token used:

JavaScript

And this is the token (payload) decoded:

JavaScript

This is a image of the decoded JWT from jwt.io

And this this is the request I use

Advertisement

Answer

I made a mistake, while sending the request in Postman. Instead of passing the JWT in the Header I passed it as an Parameter, which of course won’t work because I have nothing that extracts the JWT from the URL🤦‍♂️

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement