title: Python Social Auth for Django raises Authforbidden exception
body: <p>I am using Django 1.10 with python 2.7 and social-auth-app-django (1.2.0). It is part of the  Python Social Auth library.</p>
  
  <p>I wish to restrict login to only the domain ID of my company I've therefore used this setting from the library.</p>
  
  <pre><code>SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS=['mycompany.in']
  </code></pre>
  
  <p>Now if you try to login with any other domain as expected it throws an error.</p>
  
  <p>My goal is to catch this exception and show a custom page to the user. But for the life of me I am unable to do so.</p>
  
  <p>If I set Debug to False it redirects the user to my</p>
  
  <pre><code>LOGIN_ERROR_URL='/'
  </code></pre>
  
  <p>page but am unable to pass my custom message to the user</p>
  
  <p>This is part of my setting.py</p>
  
  <p><code>DEBUG = False</code></p>
  
  <pre><code>    MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
      'social_django.middleware.SocialAuthExceptionMiddleware',
  ]
  
  #social auth
  SOCIAL_AUTH_GOOGLE_OAUTH2_KEY= "9******6.apps.googleusercontent.com"
  SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET="W*****x"
  SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS=['mycompany.in']
  LOGIN_URL = 'login'
  LOGIN_REDIRECT_URL = 'upload_file'
  LOGOUT_URL = 'logout'
  LOGIN_ERROR_URL='logout
  </code></pre>
  
  <p>In my view I've this code to handle the exception</p>
  
  <pre><code>from social_django.middleware import SocialAuthExceptionMiddleware
  from social_core.exceptions import AuthForbidden
  
  
      class SocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
        def process_exception(self, request, exception):
          print "exception occured"
          if hasattr(social_exceptions, 'AuthForbidden'):
            print "hello two"
            return HttpResponse("I'm a exception %s" % exception)
          else:
            print "other exception"
            raise exception
  </code></pre>
  
  <p>I've even tried with </p>
  
  <pre><code>def process_template_response(self):
      print "response"'
  
  def get_redirect_uri(request, exception):
      print "URL"
  </code></pre>
  
  <p>But to no avail. </p>
  
  <p>I've followed these link
  <a href="https://stackoverflow.com/questions/20907276/python-social-auth-authcanceled-exception">python-social-auth AuthCanceled exception</a></p>
  
  <p>and </p>
  
  <p><a href="http://python-social-auth-docs.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware" rel="noreferrer">http://python-social-auth-docs.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware</a></p>
  
  <p>This is the output when debug is set to False:</p>
  
  <blockquote>
    <p>"AuthForbidden at /app/oauth/complete/google-oauth2/ 
    Your credentials aren't allowed"</p>
  </blockquote>