|
30 | 30 | import binascii
|
31 | 31 | import httplib2
|
32 | 32 |
|
| 33 | +from urlparse import parse_qs, parse_qsl |
| 34 | + |
33 | 35 | try:
|
34 |
| - from urlparse import parse_qs, parse_qsl |
| 36 | + from hashlib import sha1 |
| 37 | + sha = sha1 |
35 | 38 | except ImportError:
|
36 |
| - from cgi import parse_qs, parse_qsl |
37 |
| - |
| 39 | + # hashlib was added in Python 2.5 |
| 40 | + import sha |
38 | 41 |
|
39 | 42 | import _version
|
40 | 43 |
|
@@ -602,7 +605,6 @@ def add_signature_method(self, signature_method):
|
602 | 605 | def verify_request(self, request, consumer, token):
|
603 | 606 | """Verifies an api call and checks all the parameters."""
|
604 | 607 |
|
605 |
| - version = self._get_version(request) |
606 | 608 | self._check_signature(request, consumer, token)
|
607 | 609 | parameters = request.get_nonoauth_parameters()
|
608 | 610 | return parameters
|
@@ -661,7 +663,7 @@ def _check_signature(self, request, consumer, token):
|
661 | 663 | raise Error('Invalid signature. Expected signature base '
|
662 | 664 | 'string: %s' % base)
|
663 | 665 |
|
664 |
| - built = signature_method.sign(request, consumer, token) |
| 666 | + signature_method.sign(request, consumer, token) |
665 | 667 |
|
666 | 668 | def _check_timestamp(self, timestamp):
|
667 | 669 | """Verify that timestamp is recentish."""
|
@@ -733,12 +735,6 @@ def sign(self, request, consumer, token):
|
733 | 735 | """Builds the base signature string."""
|
734 | 736 | key, raw = self.signing_base(request, consumer, token)
|
735 | 737 |
|
736 |
| - # HMAC object. |
737 |
| - try: |
738 |
| - from hashlib import sha1 as sha |
739 |
| - except ImportError: |
740 |
| - import sha # Deprecated |
741 |
| - |
742 | 738 | hashed = hmac.new(key, raw, sha)
|
743 | 739 |
|
744 | 740 | # Calculate the digest base 64.
|
|
0 commit comments