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

Generated 2FA code is invalid and different from google Authenicator app #151

Open
Mobeen-Ghaffar opened this issue Feb 12, 2024 · 3 comments

Comments

@Mobeen-Ghaffar
Copy link

Mobeen-Ghaffar commented Feb 12, 2024

Here is my Code:


 var userToken = speakeasy.totp({
          secret: screte_code,
          digits: 6,
          encoding: 'base32',
          algorithm: 'sha1',
          // encoding: 'base32'
        });
        var verified = speakeasy.totp.verify(
          {
            secret: screte_code,
            encoding: 'base32',
            token: userToken,
          }
        );

Sometime it generate correct code and sometime incorrect. How can I fix this issue?
What I am doing wrong ?

@davidhorac3
Copy link

davidhorac3 commented Jun 28, 2024

+1
I'm actually never getting the same code with GoogleAuth - this lib seems to be working fine, but it never generates matching code

EDIT: Ah now I see this is unmaintened... sorry.

@rutvik-mpc
Copy link

+1
I also facing the same issue , it is working 90% user but for 10% it is not working.

@LeGeek01
Copy link

hey there, I also facing the same issue and found a solution!
it looks like you need to use SHA256 algorithm in order to use a secret in google authenticator, and if you use the qr code you need to remove the "algo" setting in the url

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

4 participants