Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to login to facebook using django rest framework?


Asked by Coen Reid on Dec 02, 2021 Django



1. Select the desired social network provider. i.e facebook, google, twitter, github. 2. Send a log in request to the social network provider. 3. Register and login the user. 4. You can decide to get an authentication token from login so as to use it to access protected endpoints. Before getting started, create an app at developers.facebook.
Also,
Authenticating with Django is a three step process: The first step is to get issued a CSRF token. To do this, visit the authentication URL. In most Django Rest Framework applications, this is /auth/login . This page has this familiar login form when viewed from a browser:
Consequently, This module provides OAuth2 social authentication support for applications in Django REST Framework. The aim of this package is to help set up social authentication for your REST API. It also helps setting up your OAuth2 provider. This package relies on python-social-auth and django-oauth-toolkit .
Additionally,
This project will utilize Pipenv. A production-ready tool that aims to bring the best of all packaging worlds to the Python world. It harnesses Pipfile, pip, and virtualenv into one single command. This tutorial assumes that the reader has basic working knowledge with Django. You also need to have an account with Facebook, Instagram, and LinkedIn.
Just so,
If you want to enable a social backend (e.g. Facebook), check the docs of python-social-auth on supported backends and django-social-auth on backend configuration. Now that the installation is done, let's try out the various functionality. We will assume for the following examples that the REST API is reachable on http://localhost:8000.