Same secret with Google Authenticator and SpeakEasy, different tokens
See original GitHub issueHey, 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:
- Created 6 years ago
- Comments:6
Top GitHub Comments
No problem, glad to hear this solved the issue.
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 isascii
. Specify the encoding asbase32
(see documentation) and let me know if that fixes the issue.