From: Michael Armida Date: Tue, 6 Mar 2012 06:35:45 +0000 (-0800) Subject: make BaseOAuth2 behave like ConsumerBasedOAuth when requesting an access token leads... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=2a467761fd6bd75bd048ce1ed5e7a75a97d95922;p=django-social-auth.git make BaseOAuth2 behave like ConsumerBasedOAuth when requesting an access token leads to a HTTP 400; previously it lead to an unhandled exception, although I don't know that "Authentication process canceled" is much better --- diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index ceaffcf..766bb6f 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -658,6 +658,11 @@ class BaseOAuth2(BaseOAuth): try: response = simplejson.loads(urlopen(request).read()) + except HTTPError, e: + if e.code == 400: + raise AuthCanceled(self) + else: + raise except (ValueError, KeyError): raise AuthUnknownError(self)