Home > Software engineering >  How to generate expiration time for refresh token?
How to generate expiration time for refresh token?

Time:11-06

I need to generate the expiration time for refresh token, refresh token should expires in 200 days, how to generate exp time for this? Is there any libraries? And what format should be? unix, maybe YYYY/MM/DD etc? Any options please, thank you!

CodePudding user response:

You could use json web tokens and make use of the jsonwebtoken package.

https://www.npmjs.com/package/jsonwebtoken

Specifically, if you make use of the options.expiresIn value this will take care of the date calculations and logic for you. When using the verify() method it will fail if the token has expired.

  • Related