pyauth / pyotp

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

the example doesn't work in google authenticator. #39

Closed baiyunping333 closed 7 years ago

baiyunping333 commented 7 years ago

I use the latest google authenticator in app store. I scan the example qr code, and add it to google authenticator. But with the code:

import pyotp
totp = pyotp.TOTP("JBSWY3DPEHPK3PXP")
print("Current OTP:", totp.now())

I get :

('Current OTP:', 94511)

meanwhile in the google authenticaor is 456629. when I use a golang libary opt, that works correctly. Is this a bug?

kislyuk commented 7 years ago

I just double checked in both Google Authenticator and Authy, and everything works as expected.

The most likely explanation is that your computer has clock drift. Make sure to sync your clocks on your computer and phone using NTP, and try again.

baiyunping333 commented 7 years ago

Yes, my phone delay 10s than my computer. test in pyotp: the pyotp code is different from google authenticator completely; test in opt, the code is same of google authenticator,but expire 10 seconds faster than google authenticator.

baiyunping333 commented 7 years ago

My authenticator work well in github account, google account. I think maybe there is implementation fault in pyotp?

kislyuk commented 7 years ago

Maybe, but I'm unable to reproduce your issue. If you want help, please provide a complete description of how to reproduce the bug, including full source code and a precise description of steps that you took.