from oauth2 import Consumer as OAuthConsumer, Token, Request as OAuthRequest, \
SignatureMethod_HMAC_SHA1
+from django.db import models
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth.backends import ModelBackend
from social_auth.backends.exceptions import StopPipeline
+if getattr(settings, 'SOCIAL_AUTH_USER_MODEL', None):
+ User = models.get_model(*settings.SOCIAL_AUTH_USER_MODEL.rsplit('.', 1))
+else:
+ from django.contrib.auth.models import User
+
+
# OpenID configuration
OLD_AX_ATTRS = [
('http://schema.openid.net/contact/email', 'old_email'),
"""
raise NotImplementedError('Implement in subclass')
+ def get_user(self, user_id):
+ """Return user with given ID from the User model used by this backend"""
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None
class OAuthBackend(SocialAuthBackend):
"""OAuth authentication backend base class.