Closed tuckerww closed 3 years ago
Aha! I have discovered the issue.
If you set the encryption algorithm to SHA512 then it doesn't work with the Google Authenticator App, but if you leave it as default then it works.
So in my above example I simply removed this line:
$google2fa->setAlgorithm('sha512');
This is because
Currently, the algorithm parameter is ignored by the Google Authenticator implementations.
So it uses SHA1 in the app no matter what you specify.
https://github.com/google/google-authenticator/wiki/Key-Uri-Format#algorithm
Closing this.
It appears that neither the Google Authenticator nor the Authy app generate valid codes, whereas other TOTP apps such as iPhone's built-in 2FA/password manager and the FreeOTP+ app on Android work fine.
My suspicion is that Google and/or Authy updated something in their codebases so that they're no longer compatible with the way the google2fa library generates either the secret or the valid auth-codes.
I tested both by scanning QR codes and by manually entering the secrets.
I also ensured that NTP is running on the server and that the date/time match up. Just in case I even tried passing an extremely large
$window
(100) to$google2fa->verifyKey()
but that doesn't seem to be the issue.Example Code:
PHP Version