简体   繁体   English

如何为刷新令牌生成过期时间?

[英]How to generate expiration time for refresh token?

I need to generate the expiration time for refresh token, refresh token should expires in 200 days, how to generate exp time for this?我需要为刷新令牌生成过期时间,刷新令牌应该在 200 天后过期,如何为此生成 exp 时间? Is there any libraries?有图书馆吗? And what format should be?应该是什么格式? unix, maybe YYYY/MM/DD etc? unix,也许是 YYYY/MM/DD 等? Any options please, thank you!请提供任何选项,谢谢!

You could use json web tokens and make use of the jsonwebtoken package.您可以使用 json web 令牌并使用jsonwebtoken包。

https://www.npmjs.com/package/jsonwebtoken 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.具体来说,如果您使用options.expiresIn值,这将为您处理日期计算和逻辑。 When using the verify() method it will fail if the token has expired.使用verify()方法时,如果令牌已过期,它将失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM