summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gouldin <david@gould.in>2012-04-24 09:07:42 -0700
committerDavid Gouldin <david@gould.in>2012-04-24 09:07:42 -0700
commitd17fa0ef84b769bf48faab57cb00456e4e1a7e53 (patch)
tree395641f65af88fb9236ee61f1d444e7128f991e9
parent183353d029f5f6dfad0bc3b3682ba811b3838de3 (diff)
downloadoauthlib-d17fa0ef84b769bf48faab57cb00456e4e1a7e53.tar.gz
Changing signatures.construct_base_string to more closely follow the spec documentation.
-rw-r--r--oauthlib/oauth1/rfc5849/signature.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py
index 385c7e8..e641f0e 100644
--- a/oauthlib/oauth1/rfc5849/signature.py
+++ b/oauthlib/oauth1/rfc5849/signature.py
@@ -65,22 +65,35 @@ def construct_base_string(http_method, base_string_uri,
# The signature base string is constructed by concatenating together,
# in order, the following HTTP request elements:
- return u'&'.join((
- # 1. The HTTP request method in uppercase. For example: "HEAD",
- # "GET", "POST", etc. If the request uses a custom HTTP method, it
- # MUST be encoded (`Section 3.6`_).
- # .. _`Section 3.6`: http://tools.ietf.org/html/rfc5849#section-3.6
- utils.escape(http_method.upper()),
-
- # 2. An "&" character (ASCII code 38).
- utils.escape(base_string_uri),
-
- # 3. The base string URI from `Section 3.4.1.2`_, after being encoded
- # (`Section 3.6`_).
- # .. _`section 3.4.1.1`: http://tools.ietf.org/html/rfc5849#section-3.4.1.2
- # .. _`Section 3.4.6`: http://tools.ietf.org/html/rfc5849#section-3.4.6
- utils.escape(normalized_encoded_request_parameters),
- ))
+
+ # 1. The HTTP request method in uppercase. For example: "HEAD",
+ # "GET", "POST", etc. If the request uses a custom HTTP method, it
+ # MUST be encoded (`Section 3.6`_).
+ #
+ # .. _`Section 3.6`: http://tools.ietf.org/html/rfc5849#section-3.6
+ base_string = utils.escape(http_method.upper())
+
+ # 2. An "&" character (ASCII code 38).
+ base_string += u'&'
+
+ # 3. The base string URI from `Section 3.4.1.2`_, after being encoded
+ # (`Section 3.6`_).
+ #
+ # .. _`Section 3.4.1.2`: http://tools.ietf.org/html/rfc5849#section-3.4.1.2
+ # .. _`Section 3.4.6`: http://tools.ietf.org/html/rfc5849#section-3.4.6
+ base_string += utils.escape(base_string_uri),
+
+ # 4. An "&" character (ASCII code 38).
+ base_string += u'&'
+
+ # 5. The request parameters as normalized in `Section 3.4.1.3.2`_, after
+ # being encoded (`Section 3.6`).
+ #
+ # .. _`Section 3.4.1.3.2`: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2
+ # .. _`Section 3.4.6`: http://tools.ietf.org/html/rfc5849#section-3.4.6
+ base_string += utils.escape(normalized_encoded_request_parameters)
+
+ return base_string
def normalize_base_string_uri(uri):