omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

SocialAuthExceptionMiddleware needs updating to work with Django 1.10 #953

Closed simonwiles closed 8 years ago

simonwiles commented 8 years ago

If social.apps.django_app.middleware.SocialAuthExceptionMiddleware is added to Django 1.10's new (default) MIDDLEWARE setting (as opposed to MIDDLEWARE_CLASSES), Django will fail to start. Ideally the middleware should be updated (using django.utils.deprecation.MiddlewareMixin in the short-term), and the documentation should be updated too.

Ref: https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-middleware

RevolutionTech commented 8 years ago

+1

xgt001 commented 8 years ago

+1, faced the same issue

for folks who came Googling here, looking into handling denied oauth flow for Google OAuth, you can use a basic Django 1.10 complaint middleware like this

from django.shortcuts import render_to_response

class MySocialAuthExceptionMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        if request.method == 'GET':
            if 'access_denied' in request.META['QUERY_STRING']:
                print "User has denied access"
                return render_to_response('your_view.html')
        response = self.get_response(request)

        return response
felipe3dfx commented 8 years ago

+1

jschneier commented 8 years ago

I just opened #1031 can you verify if it works for you?

RevolutionTech commented 8 years ago

1031 works for me, all tests now passing using the MIDDLEWARE setting.