[Python-modules-commits] [python-social-auth] 94/322: Define methods to customize urls in OAuth2 backends
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:12:53 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.10
in repository python-social-auth.
commit 6348c63b6ed569f2b4314eef5158e48bbaa3b2f9
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date: Tue Feb 3 02:02:13 2015 -0200
Define methods to customize urls in OAuth2 backends
---
examples/django_example/example/settings.py | 1 +
social/backends/oauth.py | 15 ++++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/examples/django_example/example/settings.py b/examples/django_example/example/settings.py
index 7ea0aaa..2ba9170 100644
--- a/examples/django_example/example/settings.py
+++ b/examples/django_example/example/settings.py
@@ -159,6 +159,7 @@ AUTHENTICATION_BACKENDS = (
'social.backends.mendeley.MendeleyOAuth2',
'social.backends.mineid.MineIDOAuth2',
'social.backends.mixcloud.MixcloudOAuth2',
+ 'social.backends.nationbuilder.NationBuilderOAuth2',
'social.backends.odnoklassniki.OdnoklassnikiOAuth2',
'social.backends.open_id.OpenIdAuth',
'social.backends.openstreetmap.OpenStreetMapOAuth',
diff --git a/social/backends/oauth.py b/social/backends/oauth.py
index 1696439..0e33a04 100644
--- a/social/backends/oauth.py
+++ b/social/backends/oauth.py
@@ -324,7 +324,7 @@ class BaseOAuth2(OAuthAuth):
# redirect_uri matching is strictly enforced, so match the
# providers value exactly.
params = unquote(params)
- return self.AUTHORIZATION_URL + '?' + params
+ return '{0}?{1}'.format(self.authorization_url(), params)
def auth_complete_params(self, state=None):
client_id, client_secret = self.get_key_and_secret()
@@ -358,7 +358,7 @@ class BaseOAuth2(OAuthAuth):
self.process_error(self.data)
try:
response = self.request_access_token(
- self.ACCESS_TOKEN_URL,
+ self.access_token_url(),
data=self.auth_complete_params(state),
headers=self.auth_headers(),
method=self.ACCESS_TOKEN_METHOD
@@ -396,7 +396,7 @@ class BaseOAuth2(OAuthAuth):
def refresh_token(self, token, *args, **kwargs):
params = self.refresh_token_params(token, *args, **kwargs)
- url = self.REFRESH_TOKEN_URL or self.ACCESS_TOKEN_URL
+ url = self.refresh_token_url()
method = self.REFRESH_TOKEN_METHOD
key = 'params' if method == 'GET' else 'data'
request_args = {'headers': self.auth_headers(),
@@ -404,3 +404,12 @@ class BaseOAuth2(OAuthAuth):
key: params}
request = self.request(url, **request_args)
return self.process_refresh_token_response(request, *args, **kwargs)
+
+ def authorization_url(self):
+ return self.AUTHORIZATION_URL
+
+ def access_token_url(self):
+ return self.ACCESS_TOKEN_URL
+
+ def refresh_token_url(self):
+ return self.REFRESH_TOKEN_URL or self.access_token_url()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list