Django REST Framework and python-social-auth for user registration / login

I need to implement some REST api for a mobile application.

I would like to use the Django REST framework.

The user (mobile side) can register an account only using Facebook, I would use python-social-auth for this registration / login.

I am new to this, so I have seen many tutorials / documents / examples about this.

I only found a complete tutorial about Django + python_social_auth, but I would know exactly how best to do user registration / login using REST-api.

Where can I find a complete example?

In my simple test, I also have a problem: When I try to use this example:

@psa('social:complete') def register_by_access_token(request, backend): # This view expects an access_token GET parameter, if it needed, # request.backend and request.strategy will be loaded with the current # backend and strategy. token = request.GET.get('access_token') user = request.backend.do_auth(request.GET.get('access_token')) if user: login(request, user) return 'OK' else: return 'ERROR' 

I get this error:

u'social 'is not a registered namespace

I also tried adding this SOCIAL_AUTH_URL_NAMESPACE = 'myApp' to my settings, but this did not solve the problem.

+7
python rest django django-rest-framework python-social-auth
source share
2 answers

If not too late, why not use https://github.com/pennersr/django-allauth and https://github.com/Tivix/django-rest-auth , which are designed to work together and simplify access to tokens / passwords reset based on API (log) / passwords reset from tokens, etc.

+6
source share

I know that the user has already selected the answer, but since this answer directs us to another library, here is my answer, if someone needs it later:

"social" is the namespace you must provide to the URLs provided by python-social-auth. You should include the following line in the urlpatterns list of your urls.py project:

 urlpatterns = [ url(r'^social/', include('social.apps.django_app.urls', namespace="social") # All other remaining urls here. ] 
+2
source share

All Articles