wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't work for some reason

prostovasya opened this issue · comments

Hi
Tried to implement this code to my project, but all the times the verification code was invalid. I used a
GoogleAuthenticatorConfigBuilder instance with the different settings (digits, windows, key representations), but always failure.

I use your code with Google Authenticator. I don't know. May be there are a special settings for it ?
Can you help me ?

By default I use code bellow.

  1. Here is creation user's creditians
      val builder = new GoogleAuthenticatorConfigBuilder()
      val gAuth = new GoogleAuthenticator(builder.build())
      gAuth.setCredentialRepository(new CreditRepository)

      val creditiands = gAuth.createCredentials("sa")
      val otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("SomeSite", "sa", creditiands)

As CreditRepository I just used a something like a Mock object:

class CreditRepository extends ICredentialRepository{ 
  override def getSecretKey(userName: String): String = {
    return "KR52HV2U5Z4DWGLJ"
  }
  override def saveUserCredentials(
                            userName: String, 
                            secretKey: String, 
                            validationCode: Int, 
                            scratchCodes: util.List[Integer]): Unit = { }
}
  1. Here is a checking:
      var builder = new GoogleAuthenticatorConfigBuilder()
      var gAuth = new GoogleAuthenticator(builder.build())
      gAuth.setCredentialRepository(new CreditRepository)

      val isCodeValid =  gAuth.authorizeUser("sa", <verificationCode>)

Once again, is the telephone clock properly synchronised?

If you use the Google Authenticator application you don't need any tweaking, since this library uses compatible defaults.

I'm afraid in general there is no way to easy way to troubleshoot your problem with fragments. And in this case the issue is so generic that I can hardly figure out how I could help you.

Please, respect this etiquette:

  • If you want to open a new issue on a separate subject, do so, but do not comment on another one.
  • Furthermore, this issue is closed. If can reopen it but as I already told you, please be specific.
  • Last but not least "does wrong QR code" means nothing: it's non reproducible and give no information whatsoever.

I'm thus going to delete the previous comment.