I noted down the secret key from the platform where I am trying to signin and then scanned the code through Microsoft Authenticator Application.
Now I am trying to get the same otp using python libraries like pyotp, otpauth, onetimepassword like I have in the MS Authenticator. Until yesterday, pyotp was generating the correct otp for me. But now its not giving me the same otp.
OTP generated by MS Authenticator is working fine but the libraries are generating different OTP's and the secret is same for all of them.
Here is the code that I was using:
import pyotp
import time
totp = pyotp.TOTP('ABCDEFG')
otp = totp.now()
print(otp)
Second one which I tried:
import otpauth
totp = otpauth.TOTP(b"ABCDEF")
# generate a code for now
code: int = totp.generate()
# you may want to convert it to string
str_code: str = totp.string_code(code)
print(str_code)
import onetimepass as otp
secret_key = 'ABCDEFG'
otp_code = otp.get_totp(secret_key)
print(otp_code)
This code (last) is giving me this error: binascii.Error: Incorrect padding
I am getting different codes from both the libraries and Authenticator application is showing me something else. Is there anything I am missing out or Is there anything else which I can consider?