I have written a python flask application in which app generate totp for validation. (Python 2.7)
I use onetimepass library to validate totp against the application secret.
is_valid = otp.valid_totp(token=my_token, secret=my_secret)
Answer was simple as my_token was coming as string and i was converting it to a number. Adding this before converting to a number did the trick:
my_token.lstrip("0") #removes leading characters