Comments (3)
Thanks for your report. I am unable to reproduce this issue. Can you please provide a full reproduction, including the code you used, the expected outcome, and the observed outcome?
from pyotp.
I have also encountered issues related to interval. I have written the following test, which fails, although the interval is set to 120 seconds (greater than tested waiting times):
from time import sleep
import pyotp
import pytest
@pytest.mark.parametrize('wait', (25, 55, 85, 105, 115))
def test_totp(wait: int) -> None:
totp = pyotp.TOTP(pyotp.random_base32(), interval=120)
code = totp.now()
sleep(wait)
assert totp.verify(code)
And here are the results:
============================================ short test summary info =============================================
FAILED test-totp-interval.py::test_totp[55] - AssertionError: assert False
FAILED test-totp-interval.py::test_totp[105] - AssertionError: assert False
FAILED test-totp-interval.py::test_totp[115] - AssertionError: assert False
==================================== 3 failed, 2 passed in 385.04s (0:06:25) =====================================
Testing environment:
- Python 3.11.3
- pyotp 2.8.0
- pytest 7.3.2
from pyotp.
@vladimir-poghosyan that is a misunderstanding of how TOTP works. The interval doesn't start when your test starts, it starts when the time since the epoch modulo the interval is zero.
I am going to close this issue now, since neither report has a valid reproduction.
from pyotp.
Related Issues (20)
- Increasing the duration of TOTP for Google Authenticator from 30 seconds to custom value such as 10 minutes? HOT 1
- Cannot decode URI due case-sensitivity HOT 1
- Support for Synology 2FA? HOT 3
- binascii.Error: Non-base32 digit found when using digest parameter for HMAC-SHA-512 HOT 2
- HOTP Pinpoint Counter used for Auth? HOT 1
- '@' symbol in name argument of `build_uri` utility function HOT 4
- want to store hashed form of base32secret HOT 4
- Discord 2fa HOT 1
- [ Tested on Okta MFA ] QRCode scanned doesn't have any "secret=" and hence unable to get required secret HOT 3
- how to pull from database and verify? HOT 1
- Wrong current OTP
- error: subprocess-exited-with-error HOT 1
- Invalid TOTP, please try again HOT 2
- binascii.Error: Non-base32 digit found HOT 2
- wishlist: Mention command line interface
- Some questions about pytop.random_hex() HOT 4
- *Deleted* HOT 1
- Don't use mutable objects as default arguments HOT 3
- Paper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyotp.