[Python-modules-commits] [python-social-auth] 237/322: Raise error if token was passed but it's incomplete. Fixes #574

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:13:14 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 e67b622d57f850d8157d2e6ff2fd49d209b01918
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date:   Tue Apr 7 13:17:27 2015 -0300

    Raise error if token was passed but it's incomplete. Fixes #574
---
 social/backends/oauth.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/social/backends/oauth.py b/social/backends/oauth.py
index d05b4ee..2b6dfbd 100644
--- a/social/backends/oauth.py
+++ b/social/backends/oauth.py
@@ -265,14 +265,23 @@ class BaseOAuth1(OAuthAuth):
                    signature_type=SIGNATURE_TYPE_AUTH_HEADER):
         key, secret = self.get_key_and_secret()
         oauth_verifier = oauth_verifier or self.data.get('oauth_verifier')
-        token = token or {}
+        if token:
+            resource_owner_key = token.get('oauth_token')
+            resource_owner_secret = token.get('oauth_token_secret')
+            if not resource_owner_key:
+                raise AuthTokenError(self, 'Missing oauth_token')
+            if not resource_owner_secret:
+                raise AuthTokenError(self, 'Missing oauth_token_secret')
+        else:
+            resource_owner_key = None
+            resource_owner_secret = None
         # decoding='utf-8' produces errors with python-requests on Python3
         # since the final URL will be of type bytes
         decoding = None if six.PY3 else 'utf-8'
         state = self.get_or_create_state()
         return OAuth1(key, secret,
-                      resource_owner_key=token.get('oauth_token'),
-                      resource_owner_secret=token.get('oauth_token_secret'),
+                      resource_owner_key=resource_owner_key,
+                      resource_owner_secret=resource_owner_secret,
                       callback_uri=self.get_redirect_uri(state),
                       verifier=oauth_verifier,
                       signature_type=signature_type,

-- 
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