Skip to content

OTP verification failed when time delta is less than period #89

Open
@Circles24

Description

@Circles24

I'm not able to validate a TOTP even when time delta is less than period specified, lets say the OTP was generated on x timestamp then validating OTP on x+200 timestamp is failing even when period specified is 300.

The issue is not reproducible at go playground, there the validation is working fine, here's the go playground link : https://go.dev/play/p/xv8TM8pKlq6
This is the go version I'm using at my machine

➜  temp git:(main) ✗ go version  
go version go1.21.3 darwin/amd64

library version

github.com/pquerna/otp v1.4.0

logs from my machine

➜  temp git:(main) ✗ go run main.go
2023/11/09 07:48:34 otp generated 633653
2023/11/09 07:48:34 2023-11-09 07:48:34.344927 +0530 IST m=+0.000137523
2023/11/09 07:48:34 2023-11-09 07:51:54.344927 +0530 IST m=+200.000137523
2023/11/09 07:48:34 otp verification failed

logs from go-playground

2009/11/10 23:00:00 otp generated 902988
2009/11/10 23:00:00 2009-11-10 23:00:00 +0000 UTC m=+0.000000001
2009/11/10 23:00:00 2009-11-10 23:03:20 +0000 UTC m=+200.000000001
2009/11/10 23:00:00 otp verified

Program exited.

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