From: Matías Aguirre Date: Fri, 27 May 2011 20:32:50 +0000 (-0300) Subject: Send orkut scope on each request, check email value properly. Closes gh-77 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=2a47497a4e749198a44c93a35b12afc647a5516f;p=django-social-auth.git Send orkut scope on each request, check email value properly. Closes gh-77 --- diff --git a/social_auth/backends/contrib/orkut.py b/social_auth/backends/contrib/orkut.py index ebd3021..9b06698 100644 --- a/social_auth/backends/contrib/orkut.py +++ b/social_auth/backends/contrib/orkut.py @@ -33,8 +33,13 @@ class OrkutBackend(OAuthBackend): def get_user_details(self, response): """Return user details from Orkut account""" + try: + emails = response['emails'][0]['value'] + except (KeyError, IndexError): + emails = '' + return {USERNAME: response['displayName'], - 'email': response['emails'][0]['value'], + 'email': emails, 'fullname': response['displayName'], 'first_name': response['name']['givenName'], 'last_name': response['name']['familyName']} @@ -65,6 +70,12 @@ class OrkutAuth(BaseGoogleOAuth): except (ValueError, KeyError): return None + def oauth_request(self, token, url, extra_params=None): + extra_params = extra_params or {} + scope = ORKUT_SCOPE + getattr(settings, 'ORKUT_EXTRA_SCOPE', []) + extra_params['scope'] = ' '.join(scope) + return super(OrkutAuth, self).oauth_request(token, url, extra_params) + # Backend definition BACKENDS = {