2. Generating token.json

After obtaining credentials.json from the previous step we can now generate token.json file which helps fetching emails.

Inorder to generate token.json file you will require gmail.py

which is available in the zip file sent to you.

  1. Make sure python is installed in your PC , you can verify this by typing python --version in the command prompt opened within the folder where both files are placed

python --version

If you are getting error you can install python by downloading the setup from https://www.python.org/downloads/arrow-up-right

2. Now we need to install certain dependencies for Gmail API to work

type cmd in the address bar of the file explorer where gmail.py and credentials.json file is located

3. Install Google client library for Python, run the following command

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

4. Once the installation is done type python gmail.py

This will open up a browser window login with your gmail account and click on continue

After this you will able to see email fetched from edis@cdslindia.co.in

NOTE : This app will be only able to read email with credentials and token json file , never share these with anyone . Also this application doesn't store any of you email messages , you may refer the source code for the same

5. Now token.json file will be generated in your directory which helps in

connect with GMail API service

Congratulation you have completed step 2 ! You can move on to step 3

Last updated