Here is a more precise answer with all the main steps. I hope it will help other people.
-
Log in into your email account: https://myaccount.google.com
-
Then go to the security part
Be sure that you have turn on two steps verification and click on “App password”
- After select email and the corresponding device
- It will generate a password that will look like this; it is this password that you have to use in your python script.
- This password will appear here; in this place, you will have the option to erase it (so it will be no longer be useful to connect to your email account).
Hope it will help other people!