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

Generate a code which will be valid for the next 30 seconds #90

Open
slimeball1234 opened this issue Sep 7, 2020 · 1 comment
Open

Comments

@slimeball1234
Copy link

Hello,

I am trying to use your library to generate a code which will be valid for the next 60s. The code I am using is:

GoogleAuthenticatorConfigBuilder gacb =
new GoogleAuthenticatorConfigBuilder()
.setWindowSize(2);

GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(gacb.build());
GoogleAuthenticatorKey googleAuthenticatorKey = googleAuthenticator.createCredentials();

String secretKey = googleAuthenticatorKey.getKey();

int code = googleAuthenticator.getTotpPassword(secretKey);

try {
Thread.sleep(30000);
} catch (InterruptedException ex) {
Logger.getLogger(MainGoogleAuthenticator.class.getName()).log(Level.SEVERE, null, ex);
}

googleAuthenticator.authorize(secretKey, code);

The code is sometimes valid, sometimes it is not. I would assume that with the default window time frame of 30 seconds, and the window size of 2, which together makes 60 s, that the generated code above will always be valid as the thread.sleep lasts only 30 s. What am I doing wrong?

Thank you,
Ivan

@Jakush
Copy link

Jakush commented Sep 22, 2023

Hey, I have same issue, it worked for me for some time, but then it started bugging and the code is sometimes valid, and valid it becomes when you have like 5-10 seconds before end.

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

2 participants