Python Flask app- leading zeros in TOTP error. (Python 2.7)
<p>I have written a python flask application in which app generate totp for validation. (Python 2.7)</p>

<p>I use onetimepass library to validate totp against the application secret. 
code:</p>

<pre><code>    json_data=request.get_json()
    my_token=json_data['OTP']
    is_valid = otp.valid_totp(token=my_token, secret=my_secret)
</code></pre>

<p>However the issue i am facing is whenever a totp comes with leading zeroes it turns into an Octal number. 
OTP is always treated as incorrect and user is unable to login.</p>

<p>How can i preserve these leading zeroes in such case? any code snippets or guidance will be of much help.</p>

<p>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:</p>

<p><code>my_token.lstrip("0") #removes leading characters</code></p>

python python-2.7 flask otp octal