re: Selenium Testing - How to sign in to Two-factor authentication? VIEW POST


Dear jsakamoto,

Thanks for your code.

However, when I am applying the below code, I'm unable to login into the aws. Can I request you to kindly help me a bit more on this, please?

import org.jboss.aerogear.security.otp.Totp;

String otpKeyStr = "6jm7n6xwitpjooh7ihewyyzeux7aqmw2"; // <- this 2FA secret key.

Totp totp = new Totp(otpKeyStr);
String twoFactorCode = totp.now(); // <- got 2FA coed at this time!

I am able to generate the MFA code but when it is getting inserted into the aws MFA page using selenium, it is throwing incorrect credentials error.

Do we need to register our aws account with the aerogear first?

Kindly suggest.

Thanks in advance!



Ok, I'll try to reproduce and resolve your problem.

But so I'm busy few weeks, my response will be late.


Hi..thanks for your response!

Few weeks !! oh okay...I was actually working on it but unable to proceed further.

I'll be waiting for your response..request you to kindly revert at your earliest convenience. Meanwhile, if you have any suggestion which I can look into kindly suggest, thanks very much for your beautiful support!!

I could compute MFA code for my AWS account by that Java sample code.

Question: Did you rewrite the sample source code at "2FA secret key" row with your own MFA secret key?

See also: gist.github.com/jsakamoto/54f77ae1...

You should capture the MFA secret key of your AWS account in an enabling MFA steps.

In this sample case above, the sample code should be bellow.

Code of Conduct Report abuse