]> git.parisson.com Git - django-social-auth.git/commitdiff
Don't set xoauth_displayname for registered Google OAuth applications. Refs #156.
authormlavin <markdlavin@gmail.com>
Sat, 29 Oct 2011 14:36:50 +0000 (10:36 -0400)
committermlavin <markdlavin@gmail.com>
Sat, 29 Oct 2011 14:36:50 +0000 (10:36 -0400)
social_auth/backends/google.py

index 621327fbc9b45148b1c4a0c989665eabbe860fdc..49d6005ff92c39d46a84cae1d84d93a748514f93 100644 (file)
@@ -122,9 +122,10 @@ class GoogleOAuth(BaseGoogleOAuth):
                 getattr(settings, 'GOOGLE_OAUTH_EXTRA_SCOPE', [])
         extra_params.update({
             'scope': ' '.join(scope),
-            'xoauth_displayname': getattr(settings, 'GOOGLE_DISPLAY_NAME',
-                                          'Social Auth')
         })
+        if not self.registered():
+            xoauth_displayname = getattr(settings, 'GOOGLE_DISPLAY_NAME', 'Social Auth')
+            extra_params['xoauth_displayname'] = xoauth_displayname
         return super(GoogleOAuth, self).oauth_request(token, url, extra_params)
 
     def get_key_and_secret(self):
@@ -143,6 +144,11 @@ class GoogleOAuth(BaseGoogleOAuth):
         """Google OAuth is always enabled because of anonymous access"""
         return True
 
+    def registered(self):
+        """Check if Google OAuth Consumer Key and Consumer Secret are set"""
+        key, secret = self.get_key_and_secret()
+        return key != 'anonymous' and secret != 'anonymous'
+
 
 # TODO: Remove this setting name check, keep for backward compatibility
 _OAUTH2_KEY_NAME = hasattr(settings, 'GOOGLE_OAUTH2_CLIENT_ID') and \