-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong canonical string created while trying multiple comma separated values in IncludedData #38
Comments
@tsibelman Could you please help me with this? or do you have any other alternatives to resolve this issue? |
@ronenfe Could you please help me with the issue here? |
Hi, please provide your usage of the library, ommiting private data. I am not sure what is getCatalogItem and what is includedData. |
Hi @ronenfe, When I have a query parameter with more than one value, it generates a URL by adding a query parameter name for each value. For example: Here includedData is one of the query parameters for the getCatalogItem endpoint and it has values like attributes, identifiers, images, and summaries. I have added my current result URL generated by the method GetCanonicalQueryParams() in AWS4RequestSigner.cs Current result: (Here you can see there is "includedData=" for each value){URL}/includedData=attributes&includedData=identifiers&includedData=images&includedData=summaries&locale=en-US&marketplaceIds=XXXXXXXXXXXXXX Expected result: (Expected result should have multiple comma separated values for one query parameter) Let me know if you need more information, Thanks. |
Hi, are you saying you found the problem that's causing the issue and fixed it? It's hard for me to understand and reproduce without you sending a sample code that is not working for you. |
Hi @ronenfe ,
I feel like changes from https://github.com/tsibelman/aws-signer-v4-dot-net/pull/25/files are causing the issue somewhere. I might be wrong, as I am not 100% sure what scenarios you want to achieve using PR. But you got the scenario that is not working in my case, right? |
I see it's commited by John Lagnese, maybe reach out for him, I can try to debug if you give me a code sample of your usage of the library. |
I see here there is no standard when sending multiple values per key in the querystring: https://stackoverflow.com/questions/24059773/correct-way-to-pass-multiple-values-for-same-parameter-name-in-get-request |
@jlagnese-allata Could you please have a look at this issue and the above conversation? @ronenfe I am not getting what actually you want as a code sample of my usage of the library? I have added some information in my very first comment by omitting private data, was it not useful? |
@krutipatel-8794 |
Hi @ronenfe |
The data for calculating "Canonical Query String" needs to do uriEncode first, which means the comma should be replaced by "%2C" https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html |
the same issue when you try to use Amazon Managed Service for Prometheus APIs for reading prometheus metrics. query={instance="987654321",label="123456789"} The solution is to change GetCanonicalQueryParams - remove Split `
` |
Same issue here signing process looks strightforward
|
I am trying to call getCatalogItem operation with multiple comma separated values in IncludedData parameter.
When I am including more than one value (i.e. attributes,identifiers,images,summaries), it has generated wrong canonical string and throws a signature error. (Note: It is adding 'includedData=' for each values)
@tsibelman I think this is caused by https://github.com/tsibelman/aws-signer-v4-dot-net/pull/25/files changes. I have tried to revert those changes in my code with some modification and it gives me correct Querystring (includedData=attributes%2Csummaries%2Cidentifiers%2Cimages&locale=en-US&marketplaceIds=XXXXXXXXXXXXXX)
I am using 1.0.3.0 package version of Aws4RequestSigner.
Generated canonical string using current code/package:
GET
/catalog/2020-12-01/items/
includedData=attributes&includedData=identifiers&includedData=images&includedData=summaries&locale=en-US&marketplaceIds=XXXXXXXXXXXXXX
host:sellingpartnerapi-fe.amazon.com
x-amz-access-token: <XXXXXXX.....>
x-amz-content-sha256:<XXXXXXX.....>
x-amz-date:20220420T001006Z
x-amz-security-token:<XXXXXXX.....>
Error:
{
"errors": [
{
"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.
The Canonical String for this request should have been
'GET
/catalog/2020-12-01/items/
includedData=attributes%2Csummaries%2Cidentifiers%2Cimages&locale=en-US&marketplaceIds=XXXXXXXXXXXXXX
host:sellingpartnerapi-fe.amazon.com
x-amz-access-token:<XXXXXXX.....>
x-amz-content-sha256:<XXXXXXX.....>
x-amz-date:20220419T235917Z
x-amz-security-token:<XXXXXXX.....>
host;x-amz-access-token;x-amz-content-sha256;x-amz-date;x-amz-security-token
<XXXXXXX.....>'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20220419T235917Z
20220419/us-west-2/execute-api/aws4_request
'
",
"code": "InvalidSignature"
}
]
}
See below for reference:
https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v2020-12-01-use-case-guide
Endpoint: GET https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/XXXXXXXXXX
?marketplaceIds=ATVPDKIKX0DER
&includedData=attributes,identifiers,images,summaries
Does anyone have any idea how I can resolve this issue?
The text was updated successfully, but these errors were encountered: