Error de Amazon MWS SignatureDoesNotMatch (Python)

Actualmente obtengo el siguiente error al intentar enviar solicitudes a Amazon Marketplace WebService:

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. 62baed22-cc14-49bd-bf34-c1eb10bc4019 

Código:

 import sys, os, base64, datetime, hashlib, hmac, urllib from time import gmtime, strftime from requests import request import urllib.parse import urllib.request import dateutil.parser def get_timestamp(): time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()) return dateutil.parser.parse(time) def calc_signature(method, domain, URI, request_description, key): sig_data = method + '\n' + \ domain.lower() + '\n' + \ URI + '\n' + \ request_description hmac_obj = hmac.new(key.encode(), sig_data.encode(), hashlib.sha256) digest = hmac_obj.digest() return urllib.parse.quote(base64.b64encode(digest), safe='-_+=/.~') SECRET_KEY = 'XXXXXXXX' AWS_ACCESS_KEY = 'XXXXXXXX' SELLER_ID = 'XXXXXXXX' MARKETPLACE_ID = 'XXXXXXXX' MWS_AUTH_TOKEN = 'XXXXXXXXXXX' Action = 'GetLowestPricedOffersForASIN' SignatureMethod = 'HmacSHA256' SignatureVersion = '2' Timestamp = get_timestamp() Version = '2011-10-01' CreatedAfter = '2011-10-01T23:00:57Z' URI = '/Products/2011-10-01' domain = 'mws.amazonservices.com' proto = 'https://' method = 'POST' ASIN = 'B004KZQVF4' itemcondition = 'New' payload = { 'AWSAccessKeyId': AWS_ACCESS_KEY, 'Action': Action, 'SellerId': SELLER_ID, 'MWSAuthToken': MWS_AUTH_TOKEN, 'SignatureVersion': SignatureVersion, 'Timestamp': '2016-01-08T05%3A32%3A48Z', 'Version': Version, 'SignatureMethod': SignatureMethod, 'CreatedAfter': CreatedAfter, 'MarketplaceId.Id.1': MARKETPLACE_ID, 'ASIN': ASIN, 'ItemCondition': itemcondition } request_description = '&'.join(['%s=%s' % (k, urllib.parse.quote(payload[k], safe='-_+=/.~').encode('utf-8')) for k in sorted(payload)]) sig = calc_signature(method, domain, URI, request_description, SECRET_KEY) url = '%s%s?%s&Signature=%s' % \ (proto+domain, URI, request_description, urllib.parse.quote(sig)) headers = { 'Host': domain, 'Content-Type': 'text/xml', 'x-amazon-user-agent': 'python-requests/1.2.0 (Language=Python)' } response = request(method, url, headers=headers) 

Salida de URL:

 https://mws.amazonservices.com/Products/2011-10-01?ASIN=XXXXXXX&AWSAccessKeyId=XXXXXXX&Action=GetLowestPricedOffersForASIN&CreatedAfter=2014-08-26T23%3A00%3A57Z&ItemCondition=New&MWSAuthToken=XXXXXXX&MarketplaceId.Id.1=XXXXXXX&SellerId=XXXXXXX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-01-13T21%3A08%3A57Z&Version=2013-09-01&Signature=hwooJu0FeDs3j26mEUN8of5buSI/QsgY54kVCUsAirw%3D 

Obviamente, hay algo malo en cómo se genera la firma, pero no puedo limitar la causa exacta.

    Bueno, lo descubrí. Simplemente cambió el método de ‘POST’ a ‘GET’.

    He estado luchando con esto por días, ¡cifras, sería algo tan simple como eso!