| 61 | return string |
| 62 | |
| 63 | def base(url, data={}, method="GET"): |
| 64 | # Signature base string: http://tools.ietf.org/html/rfc5849#section-3.4.1 |
| 65 | base = escape(utf8(method.upper())) + "&" |
| 66 | base += escape(utf8(url.rstrip("?"))) + "&" |
| 67 | base += escape(utf8("&".join(["%s=%s" % ( |
| 68 | escape(utf8(k)), |
| 69 | escape(utf8(v))) for k, v in sorted(data.items())]))) |
| 70 | return base |
| 71 | |
| 72 | def sign(url, data={}, method="GET", secret="", token="", hash=HMAC_SHA1): |
| 73 | # HMAC-SHA1 signature algorithm: http://tools.ietf.org/html/rfc5849#section-3.4.2 |