From: Stas Kravets Date: Mon, 11 Jul 2011 20:14:05 +0000 (+0400) Subject: VKontakte error checking. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f20cfdd982436eaeb9c9d1e5f3c02a62706263ba;p=django-social-auth.git VKontakte error checking. --- diff --git a/social_auth/backends/contrib/vkontakte.py b/social_auth/backends/contrib/vkontakte.py index 1efb69f..5d9191c 100644 --- a/social_auth/backends/contrib/vkontakte.py +++ b/social_auth/backends/contrib/vkontakte.py @@ -10,7 +10,7 @@ from django.contrib.auth import authenticate from django.utils import simplejson from urllib import urlencode, unquote -from urllib2 import Request, urlopen +from urllib2 import Request, urlopen, HTTPError from hashlib import md5 from time import time @@ -127,7 +127,12 @@ class VKontakteOAuth2(BaseOAuth2): if stop: return None - return super(VKontakteOAuth2, self).auth_complete(*args, **kwargs) + try: + auth_result = super(VKontakteOAuth2, self).auth_complete(*args, **kwargs) + except HTTPError: # VKontakte returns HTTPError 400 if cancelled + raise ValueError('Authentication cancelled') + + return auth_result def user_data(self, access_token): """Return user data from VKontakte OpenAPI"""