amplify-js: Q: API: 403 The request signature we calculated does not match the signature you provided
I created API through awsmobile could-api and it looks like this
hello: !com.amazonaws.mobilehub.v0.API
attributes:
name: hello
requires-signin: true
paths:
/hello: !com.amazonaws.mobilehub.v0.Function
name: hello
codeFilename: uploads/hello-20171214123204.zip
handler: lambda.handler
enableCORS: true
runtime: nodejs6.10
environment: {}
'/hello/{proxy+}': !com.amazonaws.mobilehub.v0.Function
name: hello
codeFilename: uploads/hello-20171214123204.zip
handler: lambda.handler
enableCORS: true
runtime: nodejs6.10
environment: {}
When I call it without query parameters API.get('hello', '/hello') it works fine, but if I add anything to query e.g. API.get('hello', '/hello?name=John') I will get following error
403 {“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.”}
Is my configuration wrong or what I am doing wrong?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (4 by maintainers)
@roosi @ephopper when you pass query string parameters, you need to pass them as part of the
initargument object with thequeryStringParametersobject on the API request. This is because the rest api setup with the cli is a lambda proxy integration:You can then access them within Lambda on the
event["queryStringParameters"]['...']I’m using aws-amplify-react-native and was running into this issue as well. After digging around for a bit, it appears to be coming from the canonical_request function in Signer.js. (in aws-amplify, it appears to be the same in Signer.ts) the return statement shows:
return [request.method || '/', url_info.path,… however this should beurl_info.pathnameinstead ofurl_info.pathurl_info.pathincludes the query string along with the path, whereasurl_info.pathnameis simply the path by itself. Also, if your query string has more than one parameter it will throw the same 403 error due to the parameters not being sorted per the signature version 4 specs. When I sort the parameters and modify the return statement appropriately, my calls are successfulThis helps with GETs. There’s still an issue with PUTs though.
nevermind, something really freaky mustve occurred when I made the amplify user. I see in
.aws/credentialsafter the key it for some reason appended the characters " Hide"… no clue how that happened. Any ideas? Either way,amplify initis working now that I’ve removed that.Any updates on this? This makes API unusable.