Skip to content

Commit

Permalink
Don't set xoauth_displayname for registered Google OAuth applications…
Browse files Browse the repository at this point in the history
…. Refs omab#156.
  • Loading branch information
mlavin committed Oct 29, 2011
1 parent f1c1e6f commit 6a6d0cc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions social_auth/backends/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ def oauth_request(self, token, url, extra_params=None):
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):
Expand All @@ -143,6 +144,11 @@ def enabled(cls):
"""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 \
Expand Down

0 comments on commit 6a6d0cc

Please sign in to comment.