Search code examples
pythongmail

Automating Gmail login in Python


I am writing a Python program that can login Gmail.

The purpose of this program is to check whether the username/password combination exists and is correct.

Since this program is to test the the username/password combination existence, it's no need to know any mail contents in Gmail.

The input of this program is a username and password.

The output of this program is either

successful login

or

login failure

Login failure could be:

  1. existing username+wrong password
  2. nonexisting username

My idea is to login Gmail first. Afterward, when login failure, the gmail webpage will show particular message on the login webpage. I can parse the webpage content and check whether it has that particular message.

However, I still have no idea how to login Gmail in Python. Please let me know which module can be used or write me a small piece of sample code.


Solution

  • This kind of things are like prohibited, that's why things like OAuth or OpenID are created. This kind of things permit the user to login without entering username and password. So be careful.