From: Matías Aguirre Date: Thu, 29 Mar 2012 20:47:23 +0000 (-0300) Subject: Define setting to pass extra arguments to facebook.com/me. Closes #301 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1337d6913fa7a028482f65c0a47175cae48d599f;p=django-social-auth.git Define setting to pass extra arguments to facebook.com/me. Closes #301 --- diff --git a/README.rst b/README.rst index 3865756..9e14b06 100644 --- a/README.rst +++ b/README.rst @@ -679,6 +679,11 @@ at `Facebook development resources`_: FACEBOOK_EXTENDED_PERMISSIONS = [...] +- Define ``FACEBOOK_PROFILE_EXTRA_PARAMS`` to pass extra parameters to + https://graph.facebook.com/me when gathering the user profile data, like:: + + FACEBOOK_PROFILE_EXTRA_PARAMS = {'locale': 'ru_RU'} + If you define a redirect URL in Facebook setup page, be sure to not define http://127.0.0.1:8000 or http://localhost:8000 because it won't work when testing. Instead I define http://myapp.com and setup a mapping on /etc/hosts diff --git a/doc/backends/facebook.rst b/doc/backends/facebook.rst index 49df886..94de299 100644 --- a/doc/backends/facebook.rst +++ b/doc/backends/facebook.rst @@ -16,6 +16,11 @@ at `Facebook development resources`_: FACEBOOK_EXTENDED_PERMISSIONS = [...] +- Define ``FACEBOOK_PROFILE_EXTRA_PARAMS`` to pass extra parameters to + https://graph.facebook.com/me when gathering the user profile data, like:: + + FACEBOOK_PROFILE_EXTRA_PARAMS = {'locale': 'ru_RU'} + If you define a redirect URL in Facebook setup page, be sure to not define http://127.0.0.1:8000 or http://localhost:8000 because it won't work when testing. Instead I define http://myapp.com and setup a mapping on /etc/hosts diff --git a/social_auth/backends/facebook.py b/social_auth/backends/facebook.py index 9943e47..0669340 100644 --- a/social_auth/backends/facebook.py +++ b/social_auth/backends/facebook.py @@ -62,7 +62,9 @@ class FacebookAuth(BaseOAuth2): def user_data(self, access_token): """Loads user data from service""" data = None - url = FACEBOOK_ME + urlencode({'access_token': access_token}) + params = setting('FACEBOOK_PROFILE_EXTRA_PARAMS', {}) + params['access_token'] = access_token + url = FACEBOOK_ME + urlencode(params) try: data = simplejson.load(urlopen(url))