Steps to run the program:
-
Install necessary dependencies: $ pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
-
Enable Gmail API
https://console.developers.google.com/apis/dashboard
a. Go to the dashboard, and search for Gmail API and enable it.
b. create an OAuth 2.0 client ID by creating credentials (Go to the Create Credentials button):
c. Select Desktop App as the Application type and preceed, you'll see a window like this:
d. We download our credentials file and save it as credentials.json in the current directory where we have stored the program files.
- In the program, change our_email to your address with which you created API authorization.
- The first time you run the program, you will be redirected to the browser to authenticate. This will create token.pickle file after authenticating with Google in your browser. After this, every time you run the program, authentication is not required.
- Necessary changes to be made within the program while calling search_messages() function as per the requirement.