Skip to content

suleenwong/Gmail-API-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Python Google API Challenge

This is a repository for an application to utilize the Google API using Python for Gmail operations. The Gmail API documentation by Google is available at https://developers.google.com/gmail/api/


Task

  • setup a test gmail account and enable the APIs for it
  • cover the following features:
    • send emails
    • search for specific messages in the mailbox, e.g. for keywords in subject or body text
  • a brief documentation of your steps in terms what is needed to setup this API connection, PLEASE in your words not just copy & paste from google

Requirements

  • Python (2.6 or higher)
  • A Google account with Gmail enabled
  • Google API client and Google OAuth libraries

Setup

Step 1: Clone this repository

git clone [email protected]:suleenwong/Gmail-API-Python.git

Step 2: Install the Google client library

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

Step 3: Setup and configure the Gmail API connection

For a new Gmail account, the instructions setup and configure a Gmail API connection can be found here: Gmail API setup


Step 4: Authenticate

Before running the program initial setup is necessary. Make sure a working credentials.json file from the Gmail API setup is in the project folder and the relevant Gmail account has been added as a test user for the Google Cloud project.

Next, from the command line, execute the following command:

python gmail_helper.py

Enter the account you added as test user and press Continue twice.

Once it is enabled you will see "The authentication flow has completed. You may close this window." as confirmation.


Usage

To display help:

python gmail_helper.py --help

To send an email:

python gmail_helper.py --action send -e "[email protected]" -s "galaxy" -b "hello universe"

To search emails with a keyword:

python gmail_helper.py --action search -k "hello world" 

About

Using the Google API with Python for Gmail tasks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages