Everything I learned to get a smooth Social Login functionality

“6 Hours of Debugging can save you 5 minutes of reading documentation”.

A little bit of sarcasm there but the statement is as true as 2+2=4.

Most of the time, the problems we run into always have a well-detailed answer in the documentation available but there are some instances where you feel like you’re hitting a brick wall head-on constantly.

You try one method, Error not resolved, You look up another answer and BAM, what do you know, The Error is still there.

The well-rated answers on Stack overflow have failed. You look at other answers with hopes that you will find your answer but with each and every unsuccessful attempt, your faith becomes THAT weaker.

Your eyes are now burning, You just cannot take it anymore UNTIL you find that ONE answer, not rated at all but answers your problem PERFECTLY and the next thing you know, your issue is resolved. BEST FEELING EVER.

This was me the past week and boy was it a tough week or what.

So anyway, enough with the rambling, let’s get straight to the point. I am going to be sharing EVERYTHING I learned which I believe can prove useful to get started with creating a Social Login RESTful API. Let’s get started.

The first thing needed is to install Django-rest_auth and Django- all auth. These Libraries will take care of everything you need to create a Social Login API

pip install django-rest-auth
pip install django-allauth

Once that is done, add these to your list on INSTALLED APPLICATIONS in your settings.py file followed by the settings below

INSTALLED_APPS=[""" """,
    "allauth",
    "allauth.account",
    "allauth.socialaccount",
    "allauth.socialaccount.providers.google",
]
ACCOUNT_AUTHENTICATION_METHOD = ‘email’
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False

Once the above is done, Specify the SITE_ID

SITE_ID = 1

So now that the above is good to go, We will need to set up the OAuth application via Google Developers Console.

#django #python #web-development

Getting started with Django Social Authentication
11.15 GEEK