"Key not recognized" in Google Authenticator app
Testehan opened this issue · comments
Hi,
Not sure what am i doing wrong or missing...could be that I don't fully understand what the value of the key should be..my code:
String base32Secret = TimeBasedOneTimePasswordUtil.generateBase32Secret();
String imageUrl = TimeBasedOneTimePasswordUtil.qrImageUrl("aUser@gmail.com",base32Secret);
System.out.println(imageUrl);
I click on the URL...and a QR is displayed, and when I scan it with GoogleAuthenticator, I get the error "Key not recognized"..
"aUser@gmail.com" is the email that i have in my google authenticator...
Thx!
My issue was related to the QR that was generated...The QR contained my data that was wrong .. A format like the one from below is one that works
https://chart.googleapis.com/chart?chs=500x500&cht=qr&chl=otpauth://totp/testehanApp:userMax?secret=26QIYRQJZO4SBZOT&issuer=testehanApp&digits=6&period=60
Was this a problem with the imageUrl
that was generated @Testehan ? Is it that '@' wasn't encoded? See: https://javadoc.io/static/com.j256.two-factor-auth/two-factor-auth/1.3/com/j256/twofactorauth/TimeBasedOneTimePasswordUtil.html#qrImageUrl-java.lang.String-java.lang.String-
So as mentioned in their documentation: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
Provision a TOTP key for user alice@google.com, to use with a service provided by Example, Inc:
otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
I was providing a wrong key/Label. The @ is not mandatory. Once I've used this format it worked well:
testehanApp:userMax
I also added the issuer=testehanApp
which is strongly recommended