From 05539bb78083f6ac2f99800b97d964b174b5bb2c Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Wed, 26 Oct 2011 16:30:26 -0300 Subject: [PATCH 1/3] fix handling of multivalued parameters --- oauth2/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 835270e3..d73d3418 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -420,7 +420,11 @@ def to_url(self): query = base_url[4] query = parse_qs(query) for k, v in self.items(): - query.setdefault(k, []).append(v) + # deal with multivalued parameters properly + if isinstance(v,list): + query.setdefault(k, []).extend(v) + else: + query.setdefault(k, []).append(v) try: scheme = base_url.scheme From e97b6a678ea6df38f0f1c33a5a7450714a72c38b Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Wed, 26 Oct 2011 16:42:07 -0300 Subject: [PATCH 2/3] only send oath_body_hash on POST requests. --- oauth2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index d73d3418..d0f7b114 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -488,7 +488,7 @@ def get_normalized_parameters(self): def sign_request(self, signature_method, consumer, token): """Set the signature parameter to the result of sign.""" - if not self.is_form_encoded: + if self.method not in ["GET", "HEAD"] and not self.is_form_encoded: # according to # http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html # section 4.1.1 "OAuth Consumers MUST NOT include an From cf8e17e05b516efd8f49c3a0eca0d4197630d52e Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Wed, 26 Oct 2011 16:52:53 -0300 Subject: [PATCH 3/3] be more generic, handle any itterable --- oauth2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index d0f7b114..97099114 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -421,7 +421,7 @@ def to_url(self): query = parse_qs(query) for k, v in self.items(): # deal with multivalued parameters properly - if isinstance(v,list): + if hasattr(v, "__iter__"): query.setdefault(k, []).extend(v) else: query.setdefault(k, []).append(v)