0

I'm facing the following scenario: I've got an authenticator app in which I have to insert a pin to unlock the totp that I need to use in order to perform login. I've got the authenticator URI in this format:

otpauth://totp/MY_SYSTEM:MY_USER?&secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&algorithm=SHA1&digits=6&counter=0`

I tried to automate this by using python with the following script:

import pyotp

totp=pyotp.parse_uri('otpauth://totp/MY_SYSTEM:MY_USER?secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&algorithm=SHA1&digits=6&counter=0')

print(totp.now())

But when I try to run it I obtain the following error:

 File "C:\Users\alorland\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyotp\__init__.py", line 94, in parse_uri
    return TOTP(secret, **otp_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TOTP.__init__() got an unexpected keyword argument 'initial_count'

So if I try to remove the &counter=0 parameter, it runs without any error but the totp returned doesn't match with the one shown in app. Is there anything that I am ignoring? What about the app pin for unlock the totp? is that one the missing step? Also solutions in other languages are welcome! thanks in advance

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

0 Answers0