Package: django-rest-allauth
django-rest-allauth is an authentication package for djangoQuick startInstall Dep:pip install django-rest-framework django-cors-headers requestsAdd “django_rest_allauth” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'django_rest_allauth',
    'rest_framework',
    'rest_framework.authtoken',
    'corsheaders',
]Include corsheaders in your middleware in settings.py:MIDDLEWARE = [

    'corsheaders.middleware.CorsMiddleware',

    ...
]Include DEFAULT_AUTHENTICATION_CLASSES and DEFAULT_PERMISSION_CLASSES in settings.py:REST_FRAMEWORK = {

    'DEFAULT_AUTHENTICATION_CLASSES': (

        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (

        'rest_framework.permissions.IsAuthenticated','rest_framework.permissions.AllowAny' )
}Include the django_rest_allauth URLconf in your project urls.py like this:path('django-rest-allauth/', include('django_rest_allauth.api.urls')),Set how you want your corsheaders in settings.py or whitelist your url::CORS_ALLOW_CREDENTIALS = TrueCORS_ORIGIN_ALLOW_ALL = TrueSITE_ID = 1Runpython manage.py makemigrationspython manage.py migrateto create the DjangoRestAllAuth models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a poll (you’ll need the Admin app enabled).Visithttp://127.0.0.1:8000/django-rest-allauth/to participate in the django_rest_allauth.Url EndpointsThis package uses token authenticationtoken/createusertoken/logintoken/getusertoken/editusertoken/changepasswordtoken/resetpasswordcodetoken/resetpasswordtoken/logoutauthenticatesocialusercreateuserThis is to create a userMethod: POSTAuthorization: AllowAnyfields:
{
“email”: “”,
“username”: “”,
“password”: “”,
“first_name”: “”,
“last_name”: “”
}Optional fields are username, first_name and last_nameloginThis is to login a user, it returns userdetails with token alongMethod: POSTAuthorization: AllowAnyfields:
{
“email”: “”,
“username”: “”,
“password”: “”,
}Optional either username or email can be used, or both.
It returns response with token along with it for authenticationgetuserThis is to get user details, it returns an object with the user detailsMethod: GETAuthorization: TokenedituserThis is to edituser detailsMethod: PATCHAuthorization: Tokenfields:
{
“email”: “”,
“username”: “”,
“first_name”: “”,
“last_name”: “”,
}All fields are optional, only input the field you want to changechangepasswordThis is to change user’s passwordMethod: POSTAuthorization: Tokenfields:
{
“old_password”: “”,
“new_password”: “”,
}If the old password is correct, it changes the user’s password to the new one.resetpasswordcodeThis will generate a code for the user and send back as response,  the code can be sent to the user’s email or sms, the next end point will be to accept the code and emailMethod: POSTAuthorization: AllowAnyfields:
{
“email”: “”,
“resetcode”: “”
}resetpasswordThis will accept the code, email and password, if it’s correct, the password will be changedMethod: POSTAuthorization: AllowAnyfields:
{
“email”: “”,
“resetcode”: “”,
“password”: “”
}logoutThis will delete the user’s tokenMethod: POSTAuthorization: AllowAnyauthenticatesocialuserTo authenticate a user with social media (facebook and google)Method: POSTAuthorization: AllowAnyfields:
{
“provider”: ‘’,
“token”: “”,
“email”: “”,
“username”: “”,
“first_name”: “”,
“last_name”: “”,
“social_id”: “”,
“profile_pic”: “”
}
These fields are coming from google/facebook response.provider field accepts ‘Facebook’ or ‘Google’ which ever provider being used.token is the access_token returned from google or facebook.social_id: for facebook it is “id” that is returned, for google, it is user_id.optional fields are username, first_name, last_name and profile_pic.