From: Matías Aguirre Date: Mon, 23 Apr 2012 19:18:32 +0000 (-0300) Subject: Check linkedin error response. Closes #323 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=2f3e82e2d597f2e87ff048619dea0723768918f6;p=django-social-auth.git Check linkedin error response. Closes #323 --- diff --git a/social_auth/backends/contrib/linkedin.py b/social_auth/backends/contrib/linkedin.py index 1e2a7f8..458e38b 100644 --- a/social_auth/backends/contrib/linkedin.py +++ b/social_auth/backends/contrib/linkedin.py @@ -8,6 +8,7 @@ from xml.parsers.expat import ExpatError 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' @@ -62,6 +63,17 @@ class LinkedinAuth(ConsumerBasedOAuth): 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