From: Matías Aguirre Date: Mon, 6 Feb 2012 19:06:03 +0000 (-0200) Subject: Extra arguments for request-token process. Closes #235 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=592408351272a0d87995d557be6cc7b9f6e9a8e1;p=django-social-auth.git Extra arguments for request-token process. Closes #235 --- diff --git a/README.rst b/README.rst index f758d4a..9deebfa 100644 --- a/README.rst +++ b/README.rst @@ -306,6 +306,12 @@ Configuration _AUTH_EXTRA_ARGUMENTS = {...} +- Also, you can send extra parameters on request token process by defining + settings per provider in the same way explained above but with this other + suffix:: + + _REQUEST_TOKEN_EXTRA_ARGUMENTS = {...} + - By default the application doesn't make redirects to different domains, to disable this behavior:: diff --git a/doc/configuration.rst b/doc/configuration.rst index f62a3a8..9a9c598 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -202,6 +202,12 @@ Configuration _AUTH_EXTRA_ARGUMENTS = {...} +- Also, you can send extra parameters on request token process by defining + settings per provider in the same way explained above but with this other + suffix:: + + _REQUEST_TOKEN_EXTRA_ARGUMENTS = {...} + - By default the application doesn't make redirects to different domains, to disable this behavior:: diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index 0adf4c9..fff8c30 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -319,9 +319,18 @@ class BaseAuth(object): kwargs.update({ self.AUTH_BACKEND.name: True }) return authenticate(*args, **kwargs) + def request_token_extra_arguments(self): + """Return extra arguments needed on request-token process, + setting is per backend and defined by: + _REQUEST_TOKEN_EXTRA_ARGUMENTS. + """ + backend_name = self.AUTH_BACKEND.name.upper().replace('-','_') + return setting(backend_name + '_REQUEST_TOKEN_EXTRA_ARGUMENTS', {}) + def auth_extra_arguments(self): - """Return extra argumens needed on auth process, setting is per bancked - and defined by _AUTH_EXTRA_ARGUMENTS. + """Return extra arguments needed on auth process, setting is per + backend and defined by: + _AUTH_EXTRA_ARGUMENTS. """ backend_name = self.AUTH_BACKEND.name.upper().replace('-','_') return setting(backend_name + '_AUTH_EXTRA_ARGUMENTS', {}) @@ -491,7 +500,8 @@ class ConsumerBasedOAuth(BaseOAuth): def unauthorized_token(self): """Return request for unauthorized token (first stage)""" - request = self.oauth_request(token=None, url=self.REQUEST_TOKEN_URL) + request = self.oauth_request(token=None, url=self.REQUEST_TOKEN_URL, + extra_params=self.request_token_extra_arguments()) response = self.fetch_response(request) return Token.from_string(response)