How to automate website login that uses 2-step verification using python selenium?

Viewed 426

I'm using python selenium to automate user login for a website. However, this specific website uses a 2-step authentication when logging in: After clicking login, it then sends a code to your email address, which you have to enter into the website in order to authenticate. Any ideas what I should do or how I can access that code using python selenium?

1 Answers
  1. You should log in to the website in the traditional way with selenium.
  2. Now the site will ask for the verification -> So you need to read your mails somehow.

I see 2 good ways to solve this:

  • Login to the email service with selenium in other window or tab -> Open emails-> Select the right email -> Read out the verification code with a regex argument from the email content.

OR

  • You can read your emails with IMAP -> Select the correct email with IMAP -> Once again: Read out the verification code with a regex argument from the email content.
  1. Now you got the verification code simply write it in and log in.
Related