paint-brush
Implementing Google Authentication and Fetching Mails from Scratch Using Python Djangoby@takwa
535 reads
535 reads

Implementing Google Authentication and Fetching Mails from Scratch Using Python Django

by takwaFebruary 2nd, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Google Authentication and Fetching mails from scratch means without using module which has already set up this authentication process. Let’s create Django 2.0 project and then implement Google authentication services and then extract mails. We are doing extract-mail just to show how one can ask for permission after authenticating it. We’ll be using Google API python client and oauth2client which is provided by google. Sometimes, it really hard to implement this Google authentication with these libraries as there was no proper documentation available.

Company Mentioned

Mention Thumbnail
featured image - Implementing Google Authentication and Fetching Mails from Scratch Using Python Django
takwa HackerNoon profile picture

Google Authentication and Fetching mails from scratch means without using any module which has already set up this authentication process.

We’ll be using Google API python client and oauth2client which is provided by google.

Sometimes, it really hard to implement this Google authentication with these libraries as there was no proper documentation available. But after completing this read, thing will be clear completely.

Now Let’s create Django 2.0 project and then implement Google
authentication services and then extract mails. We are doing extract
mail just to show how one can ask for permission after authenticating
it.

Step #1: Creating Django Project

The first step is to create virtual environment and then install the dependencies. So We’ll be using venv:

mkdir google-login && cd google-login

python3.5 -m venv myvenv
source myvenv/bin/activate

This command will create one folder myvenv through which we just activated virtual environment. Now type

pip freeze
pip install Django==2.0.7

That is Django version which we used but feel free to use any other
version. Now next step is to create one project, let’s name it gfglogin:

django-admin startproject gfglogin .

Since we are inside google-login directory that’s why we want django
project to be on that present directory only so for that you need to use

.
‘ at the end for present directory indication. Then create one app
to separate logic from main project, so create one app called gfgauth:

django-admin startapp gfgauth

Since we created one app. Add that app name into settings.py in INSTALLED_APP list. Now we have Django project up running, so let’s migrate it first and then check if there is any error or not.

django-admin startapp gfgauthpip freeze

Previously published at https://www.geeksforgeeks.org/python-django-google-authentication-and-fetching-mails-from-scratch/