|
29 | 29 | import hmac
|
30 | 30 | import binascii
|
31 | 31 | import httplib2
|
32 |
| -from types import ListType |
33 | 32 |
|
34 | 33 | try:
|
35 | 34 | from urlparse import parse_qs, parse_qsl
|
@@ -328,9 +327,17 @@ def get_parameter(self, parameter):
|
328 | 327 |
|
329 | 328 | def get_normalized_parameters(self):
|
330 | 329 | """Return a string that contains the parameters that must be signed."""
|
331 |
| - # 1.0a/9.1.1 states that kvp must be sorted by key, then by value |
332 |
| - items = [(k, v if type(v) != ListType else sorted(v)) for k,v in sorted(self.items()) if k != 'oauth_signature'] |
333 |
| - encoded_str = urllib.urlencode(items, True) |
| 330 | + items = [] |
| 331 | + for key, value in self.iteritems(): |
| 332 | + if key == 'oauth_signature': |
| 333 | + continue |
| 334 | + # 1.0a/9.1.1 states that kvp must be sorted by key, then by value, |
| 335 | + # so we unpack sequence values into multiple items for sorting. |
| 336 | + if hasattr(value, '__iter__'): |
| 337 | + items.extend((key, item) for item in value) |
| 338 | + else: |
| 339 | + items.append((key, value)) |
| 340 | + encoded_str = urllib.urlencode(sorted(items)) |
334 | 341 | # Encode signature parameters per Oauth Core 1.0 protocol
|
335 | 342 | # spec draft 7, section 3.6
|
336 | 343 | # (http://tools.ietf.org/html/draft-hammer-oauth-07#section-3.6)
|
|
0 commit comments