pyauth / pyotp

Python One-Time Password Library
https://pyauth.github.io/pyotp/
Other
3k stars 324 forks source link

Expiration date #42

Closed hryamzik closed 7 years ago

hryamzik commented 7 years ago

How can I get expiration date for TOTP? totp.now() without this information is a bit wired...

kislyuk commented 7 years ago

Do you mean the exact second that the timecode will expire? With default settings, you can get it like this: expires = 30 - (time.time() % 30).

kislyuk commented 7 years ago

(That's the number of seconds in the future that it will expire, add it to time.time() to get the expiration timestamp)

hryamzik commented 7 years ago

Great, thanks for explanation!