from social_auth.utils import setting
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
+from social_auth.backends.exceptions import AuthCanceled, AuthUnknownError
LINKEDIN_SERVER = 'linkedin.com'
except (ExpatError, KeyError, IndexError):
return None
+ def auth_complete(self, *args, **kwargs):
+ """Complete auth process. Check LinkedIn error response."""
+ oauth_problem = self.request.GET.get('oauth_problem')
+ if oauth_problem:
+ if oauth_problem == 'user_refused':
+ raise AuthCanceled(self, '')
+ else:
+ raise AuthUnknownError(self, 'LinkedIn error was %s' % \
+ oauth_problem)
+ return super(LinkedinAuth, self).auth_complete(*args, **kwargs)
+
def to_dict(xml):
"""Convert XML structure to dict recursively, repeated keys entries