Setting timeout to passcode
AjayPara opened this issue · comments
How can we restrict the passcode's lifetime?
I am trying it by using the setTimeStepSizeInMillis method but it doesn't seem to be working.
Can anyone help me with this?
Try this
// config builder
GoogleAuthenticatorConfig.GoogleAuthenticatorConfigBuilder builder = new GoogleAuthenticatorConfig.GoogleAuthenticatorConfigBuilder()
.setCodeDigits(8)
.setTimeStepSizeInMillis(TimeUnit.SECONDS.toMillis(60L))
.setSecretBits(80);
// config
GoogleAuthenticatorConfig config = builder.build();
// google authenticator
GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(config);
Yes, the 'lifetime' of a passcode is called step size in the TOTP RFC.