How to handle exceptions in Python Social Auth

How do I handle this kind of exception AuthAlreadyAssociated on Python Social Auth ?

All the answers that I found relate to Django Social Auth , but it seems that everything has changed since they were written.

+8
python authentication django social
source share
1 answer

This works for me.

I am creating a new middleware

 from social.apps.django_app.middleware import SocialAuthExceptionMiddleware from django.http import HttpResponse from social import exceptions as social_exceptions class MySocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware): def process_exception(self, request, exception): if hasattr(social_exceptions, exception.__class__.__name__): return HttpResponse("catched: %s" % exception) else: raise exception 

and add it to settings.py

 MIDDLEWARE_CLASSES = ( ... 'path.to.MySocialAuthExceptionMiddleware', ) 
+12
source share

All Articles