go-aws-auth icon indicating copy to clipboard operation
go-aws-auth copied to clipboard

Signature invalid when using for "Product Advertising API"

Open julienfouilhe opened this issue 10 years ago • 0 comments

My code is the following:

func (o *AWSHandler) InteractWithMethod(method, u string, values url.Values, header http.Header) (*http.Response, error) {
    var req *http.Request
    var err error

    values.Add("AWSAccessKeyId", o.config["access_key"])
    values.Add("Timestamp", time.Now().Format("2006-01-02T15:04:05Z"))
    values.Add("SignatureVersion", "3")
    if method == "GET" {
        req, err = http.NewRequest(method, u+"?"+values.Encode(), nil)
    } else {
        req, err = http.NewRequest(method, u, bytes.NewBufferString(values.Encode()))
    }
    req.Header = header
    if err != nil {
        return nil, err
    }
    awsauth.SignS3Url(req, time.Now().Add(time.Duration(10)*time.Second), awsauth.Credentials{
        AccessKeyID:     o.config["access_key"],
        SecretAccessKey: o.config["access_secret"],
    })
    resp, err := o.client.Do(req)
}

And here is the response I get:

<?xml version="1.0"?>
<ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2005-10-05/"><Error><Code>SignatureDoesNotMatch</Code><Message>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.</Message></Error><RequestId>227b35f0-bd51-4fe0-9896-aa54c25f5c68</RequestId></ItemSearchErrorResponse>

I'm pretty sure my keys are correct...

julienfouilhe avatar Feb 14 '15 01:02 julienfouilhe