[GH-ISSUE #193] Code timing incorrect #559

Closed
opened 2026-03-14 12:11:57 +03:00 by kerem · 2 comments
Owner

Originally created by @JamieCee20 on GitHub (Jan 4, 2024).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/193

I have generated the secret, and in my authenticator both entered the key and used the qr code, both return the same codes.

However, when running the Google2FA::verifyGoogle2FA($result, $code, $timeWindow); method, it always returns false until the code changes between 2-4 times. So why is the code in the verify so delayed to what the authenticator is giving me? This also means after the code keeps changing, older codes still work. My window has been changed varying between 0 and 4, still having the same issue

Originally created by @JamieCee20 on GitHub (Jan 4, 2024). Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/193 I have generated the secret, and in my authenticator both entered the key and used the qr code, both return the same codes. However, when running the `Google2FA::verifyGoogle2FA($result, $code, $timeWindow);` method, it always returns false until the code changes between 2-4 times. So why is the code in the verify so delayed to what the authenticator is giving me? This also means after the code keeps changing, older codes still work. My window has been changed varying between 0 and 4, still having the same issue
kerem closed this issue 2026-03-14 12:12:02 +03:00
Author
Owner

@Fludem commented on GitHub (Feb 12, 2024):

Hey,

Have you checked the time on the machine hosting your code?

Can you try again on a different machine?

Can you also manually pass a timestamp to the methods of a fixed time where you know what the correct outcomes are so it doesn't rely on your the hosts time?

<!-- gh-comment-id:1937977201 --> @Fludem commented on GitHub (Feb 12, 2024): Hey, Have you checked the time on the machine hosting your code? Can you try again on a different machine? Can you also manually pass a timestamp to the methods of a fixed time where you know what the correct outcomes are so it doesn't rely on your the hosts time?
Author
Owner

@JamieCee20 commented on GitHub (Feb 12, 2024):

Hey,

Have you checked the time on the machine hosting your code?

Can you try again on a different machine?

Can you also manually pass a timestamp to the methods of a fixed time where you know what the correct outcomes are so it doesn't rely on your the hosts time?

@Fludem Ah I forgot to update the ticket. Yeah, so I found out my machine was 2 minutes out of sync with the current time (Not sure how that ended up happening as it should have been set to automatic) But I correct that and its back working

<!-- gh-comment-id:1938308835 --> @JamieCee20 commented on GitHub (Feb 12, 2024): > Hey, > > Have you checked the time on the machine hosting your code? > > Can you try again on a different machine? > > Can you also manually pass a timestamp to the methods of a fixed time where you know what the correct outcomes are so it doesn't rely on your the hosts time? @Fludem Ah I forgot to update the ticket. Yeah, so I found out my machine was 2 minutes out of sync with the current time (Not sure how that ended up happening as it should have been set to automatic) But I correct that and its back working
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/google2fa#559
No description provided.