Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speakeasy.time(); not showing matching Google Auth/Console output OTP #25

Closed
Cannacoin-Project opened this issue Jul 17, 2014 · 6 comments

Comments

@Cannacoin-Project
Copy link

I attempted to use the example in the github readme to verify that the OTP generated from my phone/device matched the speakeasy.time();... Google shows one OTP, and the output to my console shows a different OTP.

Below is the code I used:

Example OTP QR: https://www.google.com/chart?chs=166x166&chld=L|0&cht=qr&chl=otpauth://totp/SecretKey%3Fsecret=KY7TSZRWFZBXCMJGHRED6PDOPBSS4WCK

    1. added QR code generated from google API to my google authenticator app
    1. speakeasy.time({key: 'KY7TSZRWFZBXCMJGHRED6PDOPBSS4WCK', encoding: 'base32'}); // see the base32 result above

Result:

  • Google Authenticator: 741825
  • Console.log(): 241101

Any suggestions?

@Cannacoin-Project
Copy link
Author

Solved my own issue, my computer datetime was not automatically sync'd at the OS level and therefore was out of time vs google's clock and couldn't provide the matching time for recreating OTP.

@markbao
Copy link
Collaborator

markbao commented Jul 20, 2014

Thanks for the update!

@Cannacoin-Project
Copy link
Author

Not a problem, now it seems I'm having an issue with my clocks not staying in perfect sync after the first QR code is generated (within the first 60 seconds). I was given a suggestion by a colleague who mentioned I should add a slight variance to the code by setting the current unix time -30 seconds and running a loop over it (ie. speakeasy.totp({key: 'secret', time: 159183717});) when verifying TOTP

Would you advice against this or does this seem like an appropriate solution?

@markbao
Copy link
Collaborator

markbao commented Jul 21, 2014

Hmm, that seems to work but it doesn't seem like a clean solution.

So it seems like you get a code at Time 0 (e.g. 159183700) and then, 30 seconds later, you're getting another code at Time 1 (e.g. 159183730) but the Time 1 code is wrong?

@Cannacoin-Project
Copy link
Author

Again I solved my own issue, the problem this time was that each time I was verifying the code via speakeasy.time({key: '3jk2h5kj2h63kj2h6kjh23jh6hlkj2h6ljk2h3h', encoding: 'base32'}); it was OUTSIDE my route middleware therefore only loading the variable on initial startup but not each subsequent request... Now that i've moved inside my middleware it's functioning as expected. Thanks for your patients!

@markbao
Copy link
Collaborator

markbao commented Jul 21, 2014

Great to hear, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant