]> git.parisson.com Git - django-social-auth.git/commitdiff
Show facebook error properly
authorMatías Aguirre <matiasaguirre@gmail.com>
Tue, 1 Feb 2011 03:09:56 +0000 (01:09 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Tue, 1 Feb 2011 03:09:56 +0000 (01:09 -0200)
social_auth/backends/facebook.py

index b79a87834873a5fb17db6dafdb4e623a7a9bff4c..c73650efbc42f2ce8f37c2b1e00f46467b1e6c5a 100644 (file)
@@ -61,16 +61,15 @@ class FacebookAuth(BaseOAuth):
             data = self.user_data(access_token)
             if data is not None:
                 if 'error' in data:
-                    raise ValueError('Authentication error')
+                    error = self.data.get('error') or 'unknown error'
+                    raise ValueError('Authentication error: %s' % error)
                 data['access_token'] = access_token
                 data['expires'] = response['expires'][0]
             kwargs.update({'response': data, FacebookBackend.name: True})
             return authenticate(*args, **kwargs)
         else:
-            description = self.data['error'] \
-                          if self.data.get('error') \
-                          else 'unknown_error'
-            raise ValueError(description)
+            error = self.data.get('error') or 'unknown error'
+            raise ValueError('Authentication error: %s' % error)
 
     def user_data(self, access_token):
         """Loads user data from service"""