I'm trying to make an API call to Amazon's SimpleDB service with Python. As an example, I'm using the simplest request there is to make, ListDomains. No matter what I try, however, the response is always "The request signature we calculated does not match the signature you provided."
This is the string I'm signing (as per documentation here):
GET
https://sdb.amazonaws.com/
/
AWSAccessKeyId=<redacted>&Action=ListDomains&SignatureMethod=HmacSHA1&SignatureVersion=2&Timestamp=2011-04-19T18%3A50%3A43&Version=2009-04-15
I'm signing it with the following code:
import base64,hashlib,hmac,time
# Sign the request
signature = hmac.new(
key=AWS_SECRET_ACCESS_KEY,
msg=string_to_sign,
digestmod=hashlib.sha1).digest()
# Base64 encode the signature
signature = base64.encodestring( signature )
I've tried it with both HmacSHA256 and HmacSHA1. Nothing seems to work. What am I doing wrong?