ezkl / go-amazon-mws-api

Amazon MWS API client
17 stars 14 forks source link

Sorting params in SignAmazonUrl gives signing error #1

Open danbopes opened 9 years ago

danbopes commented 9 years ago

I've noticed that when fetching GetLowestOfferListingsForASIN with more than 9 ASIN's (API supports up to 20), that the code below breaks the request and amazon gives signing errors: https://github.com/ezkl/go-amazon-mws-api/blob/d35bbe2c053c20b7e90fa9bc0f4caf5f0753cb8c/urlgen.go#L94-L96

After removing the offending sort code, requests worked normally for up to 20 ASIN's.

mikeshimura commented 8 years ago

I created patch for this issue

func SignAmazonUrl(origUrl *url.URL, api AmazonMWSAPI) (signedUrl string, err error) { escapeUrl := strings.Replace(origUrl.RawQuery, ",", "%2C", -1) escapeUrl = strings.Replace(escapeUrl, ":", "%3A", -1)

params := strings.Split(escapeUrl, "&")
//Mikeshimura  added 3 lines
for i:=0;i<len(params);i++{
    params[i]=strings.Replace(params[i],"=","#",-1)
}
sort.Strings(params)
    //Mikeshimura  added 3 lines
for i:=0;i<len(params);i++{
    params[i]=strings.Replace(params[i],"#","=",-1)
}

Best reagards, Mike Shimura