Skip to content

VerifyTotp fails even when using correct otpCode #72

Description

@nagarwal4

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions