Python PyOTP生成的代码与Google Authenticator生成的代码不匹配
我想在Python中实现由Google Authenticator生成的代码 Google Play上的应用程序Google Authenticator为所需的服务生成两步验证 我在我的谷歌账户上设置了2FA,他们以“bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa”的形式向我提供了密码,并注明“空格不重要” 因此,我用Python尝试了以下代码,但它不起作用 在Google Authenticator中,我已经选择了“基于时间的” 在我的计算机上运行下面的脚本的时间与在我的手机上安装Google Authenticator应用程序的时间相同Python PyOTP生成的代码与Google Authenticator生成的代码不匹配,python,google-authenticator,Python,Google Authenticator,我想在Python中实现由Google Authenticator生成的代码 Google Play上的应用程序Google Authenticator为所需的服务生成两步验证 我在我的谷歌账户上设置了2FA,他们以“bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa”的形式向我提供了密码,并注明“空格不重要” 因此,我用Python尝试了以下代码,但它不起作用 在Google Authenticator中,我已经选择了“基于时间的” 在我的计算机上运行下面的脚本的时
import pyotp, base64
totp = pyotp.TOTP( base64.b32encode("bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa") )
print "Current OTP:" + totp.now()
Google Authenticator应用程序生成的代码与我的代码不匹配
我做错了什么?您需要扫描二维码扫描仪生成的二维码。 您将得到如下结果:
'otpauth://totp/testegmail.com?secret=MYSECRET&issuer=Google'
这是正确的秘密。删除秘密中的空格,pyOTP可能不会处理此问题仅适用于智能手机(安装了Google Authenticator)