Django Angular Facebook Authentication

I want to make a very simple web application where you can log in using your facebook account.

I really like the structure of django as well as angularjs . I have an idea how to integrate these two using tastypie api framework for django.

So, if I use the backend django correctly, you will throw some JSON that can be used angular, etc.

Where I am confused is the authentication mechanism with facebook. How to integrate Facebook authentication with my application? What would be a good design for such an application?

I do not expect complete design or architecture for my application from anyone, but in some direction so that I can continue to work with the application.

Thanks:)

+4
source share
2 answers

I wrote a short article on this subject, because it seems that it has not been clearly explained anywhere. I found this easy to do with the django-rest-framework instead of tastypie, though.

Here are the basic steps used for authentication (I'm trying to add a small scheme for illustration):

  • On the angular side, the user authenticates to facebook using the Oauth.io API (it can be directly connected to the js API for Facebook).
  • The client receives a Facebook authentication token.
  • The FB current is used to request server-side authentication.
  • python-social-auth is authenticated using FB with this token.
  • The django-rest-framework sends an authentication token to the client for REST API calls.
  • The Angular client passes the token in the headers when making API calls.

You can find my article here about facebook angularjs auth with django backend

+7
source

This repo is designed with php on the server side of the authentication, but it has all the facebook login code you need for angular. This should give you an idea of ​​how to get started:

https://github.com/Terumi/AngularJS-Facebook-Login

+1
source

Source: https://habr.com/ru/post/1495228/


All Articles