From: mlavin Date: Sat, 29 Oct 2011 14:36:50 +0000 (-0400) Subject: Don't set xoauth_displayname for registered Google OAuth applications. Refs #156. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6a6d0cc61c7f4dc91f3ac5f235f03a906beae87a;p=django-social-auth.git Don't set xoauth_displayname for registered Google OAuth applications. Refs #156. --- diff --git a/social_auth/backends/google.py b/social_auth/backends/google.py index 621327f..49d6005 100644 --- a/social_auth/backends/google.py +++ b/social_auth/backends/google.py @@ -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 \