question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Same secret with Google Authenticator and SpeakEasy, different tokens

See original GitHub issue

Hey, I have obtained a TOTP shared secret key from GitHub and I have manually inserted the secret to both Google Authenticator and SpeakEasy and verified that the values are correct. I did this twice manually and once using the QR code from GitHub to set up Google Authenticator.

Here’s my SpeakEasy code, I am using literally just this line:

console.log(speakeasy.totp({ secret: '<the secret>' }));

The secret is a string in the format of 16 lowercase letters and numbers as provided by GitHub.

Google Authenticator and SpeakEasy give me totally different code. I have tried to cross the time window boundary to check if maybe SpeakEasy was giving me a token one window too old or too new, but they just seems to be completely unrelated. Needless to say GitHub won’t accept my TOTP token, but will Google Authenticator’s.

Do I miss options which I should be using? The README.md doesn’t show my use case of generating tokens from pre-shared secrets so I am not sure what I could be missing, but I think the defaults in options match what Google Authenticator is doing, so I am confused as to why the difference exists.

Steps to Reproduce:

  • Go through the GitHub flow’s for reconfiguring 2FA
  • On the QR code page, do not use the QA code but click for text code and copy that
  • Insert the secret manually into Google Authenticator and triple check it
  • Insert it also into the code above and quadruple check it
  • Confirm they do not match

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
markbaocommented, Jan 7, 2018

No problem, glad to hear this solved the issue.

2reactions
markbaocommented, Jan 7, 2018

Thanks for the detailed report. I saw you mentioned in the other thread that you checked your time already and it was accurate. I think the issue here is that the given key is base32 encoded, but the totp() function’s default encoding is ascii. Specify the encoding as base32 (see documentation) and let me know if that fixes the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing two-factor authentication using Speakeasy
Verify user tokens. The final step in two-factor authentication is verifying codes that the user enters from their authenticator app. We need to ......
Read more >
Two-Factor Authentication (2FA) Using Speakeasy and Express.
Verify User Tokens. The final step in the two-factor authentication is verifying the code that the user enters from their authenticator app. We ......
Read more >
Why do Google Authenticator and Duo produce different ...
The speakeasy library only recognises the Google Authenticator token as valid. Why does the same QR Code produce different tokens in the two ......
Read more >
speakeasy - npm
Google Authenticator and similar apps take in a QR code that holds a URL with the protocol otpauth:// , which you get automatically...
Read more >
Two Factor Authentication With TOTP Using Node.js And ...
Learn how to use Speakeasy to handle two-factor authentication (2FA) time-based one-time password (TOTP) codes with JavaScript and Node.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found