VerifyTotp fails even when using correct otpCode
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.3k
- Forks
- 179
- PR merge metrics
- No merged PRs in 30d
Description
We are using TOTP for email-based OTP verification, where the OTP is generated server-side, sent via email, and typically entered by the user within ~2 minutes.
Verification code:
var keyBytes = Base32Encoding.ToBytes(otpKey);
var totp = new Totp(keyBytes, step: 120);
var isValid = totp.VerifyTotp(otpCode, out var timeStepMatched, VerificationWindow.RfcSpecifiedNetworkDelay);
return isValid;
We observe that verification works when the OTP is entered immediately, but often returns false when the same correct OTP is entered after a short delay (sometimes well under 2 minutes).
We expected the OTP to remain valid for approximately the full 120 seconds from the moment it is generated, but this does not seem to be the case. We would appreciate clarification on whether this usage pattern is supported or if a different approach is recommended.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Totp.VerifyTotp entry point and the shown step: 120 and VerificationWindow.RfcSpecifiedNetworkDelay arguments. Clarify how validity is measured and whether server-generated email codes are supported as described; document the expected behavior or recommended approach when the answer is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- authentication, security
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100