PyOTP生成的代码与googleauthenticator生成的代码不匹配

2024-09-24 00:33:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在Python中实现由googleauthenticator生成的代码

googleplay上的应用googleauthenticator为所需的服务生成两步验证。你知道吗

我已经在我的谷歌账户上设置了2FA,他们以“bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa”的形式向我提供了密码,并注明“空格无所谓”

所以,我用Python尝试了下面的代码,但它不起作用。你知道吗

在googleauthenticator中,我已经选择了“基于时间的”

在我的电脑上运行下面的脚本的时间与在我的手机上安装googleauthenticator应用程序的时间相同。你知道吗

import pyotp, base64
totp = pyotp.TOTP( base64.b32encode("bsnz bwpn tji6 flto 5enn 6vd4 wji7 aaaa") )
print "Current OTP:" + totp.now()

googleauthenticator应用程序生成的代码与我的代码不匹配。你知道吗

我做错什么了?你知道吗


Tags: 代码应用程序时间账户totppyotpbase64aaaa
2条回答

删除秘密中的空格,pyOTP可能不会处理这个

您需要扫描二维码扫描仪生成的二维码。 您将得到如下结果:

'otpauth://totp/testegmail.com?secret=MYSECRET&issuer=Google'

这是正确的秘密。你知道吗

相关问题 更多 >