From 1337d6913fa7a028482f65c0a47175cae48d599f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Thu, 29 Mar 2012 17:47:23 -0300 Subject: [PATCH] Define setting to pass extra arguments to facebook.com/me. Closes #301 --- README.rst | 5 +++++ doc/backends/facebook.rst | 5 +++++ social_auth/backends/facebook.py | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) 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)) -- 2.39.5