JWT - Why we don't need to store tokens in database?

I discussed a question with many people and the question was - Do you store the JWT tokens in the database?

First Answer:   Yes, we do store. Whenever we got an API call we get the token from the header and match it with the tokens that we have stored in DB.

Second Answer: No, we don't store tokens in a database we simply get them verified by JWT itself. We get the token from the header and pass it JWT verify method like jwt.verify(token, secret).

What I feel is that it is not required to store the tokens in the database. Because if you will be storing tokens in the database then you'll be setting some TTL(expiry time) there and on every request you will be verifying the token with user requested token and every time you'll update the TTL. ...  Read More

Share This: