pyauth / pyotp

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

TOTP is not matching-PyOTP #128

Closed bhagy01 closed 2 years ago

bhagy01 commented 2 years ago

Hi , I am trying to implement 2FA for my "login" route. To start with I have added the below code to my app.

TOTP_KEY='JBSWY3DPEHPK3PXP' totp = pyotp.TOTP(TOTP_KEY) print(totp.now()) URI=pyotp.totp.TOTP(TOTP_KEY).provisioning_uri( name='abc@gmail.com', issuer_name='FastAPI App') print(URI)

I got the below URI: otpauth://totp/FastAPI%20App:abc%40gmail.com?secret=JBSWY3DPEHPK3PXP&issuer=FastAPI%20App

The OTP generated at the server side print(totp.now()) and the TOTP generated at the client side does not match. Please help to find what I am doing wrong here.

How to sync timezones of the server and the client?

kislyuk commented 2 years ago

Hello, thank you for your interest in PyOTP. Your usage of PyOTP appears correct. OTP algorithms take Unix time (seconds since the epoch in UTC) as input, not timezone-local time, so timezones are irrelevant. Synchronizing time between the server and the client is outside the scope of what we can support in this issue tracker, so I'm going to close this issue. If you have further details specific to PyOTP, feel free to comment, reopen, or file a new issue.