Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Angular Facebook authentication

I want to do a very simple web app where you can log-in using your facebook account.

I am very comfortable with the django framework and also angularjs. I have an idea how to integrate these two using tastypie api framework for django.

So if I am correct django's backend would be throwing some JSON which can be used by angularjs and so on.

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

I am not expecting a complete design or architecture for my app from anyone , but some direction so that I can go forward with the app .

Thanks :)

like image 523
Deepankar Bajpeyi Avatar asked Aug 04 '13 21:08

Deepankar Bajpeyi


2 Answers

I wrote a small article on this subject as it seems it was not clearly explained anywhere. I found it easily done with django-rest-framework instead of tastypie though.

Here are the main steps used to authenticate (I’ll try to add a little schema to illustrate) :

  1. On the angular side, user authenticate on facebook with Oauth.io API (it could be directly with Facebook js API).
  2. Client gets a Facebook authentication token.
  3. FB token is used to ask for authentication on server side.
  4. python-social-auth authenticate with FB with the given token.
  5. django-rest-framework sends back to client a auth token for REST API calls.
  6. Angular client passes the token in headers when making API calls.

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

like image 103
jp wizer Avatar answered Oct 20 '22 20:10

jp wizer


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

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

like image 35
Alex Muro Avatar answered Oct 20 '22 19:10

Alex Muro