0
votes

I have created a Serverless app using AWS Lambda + API Gateway + DynamoDB, by just following the example shown in the website:

https://medium.com/statuscode/serverless-ice-cream-or-create-your-serverless-node-js-micro-service-with-a-database-17a6946251e0

But during the testing when I fired this command:

~/Documents/workspaces/nodejs/ice-cream-shop $ curl -H "Content-Type: application/json" -X POST -d '{"icecreamId":"123", "name":"chocolate"}' https://0k213z6zp2.execute-api.us-east-1.amazonaws.com/latest

I got this error {"message":"Missing Authentication Token"} :

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 82 100 42 100 40 90 86 --:--:-- --:--:-- --:--:-- 176{"message":"Missing Authentication Token"}

I have already created aws_access_key_id & aws_secret_access_key and saved it in my credentials file under the .aws folder under my user folder. Still I got the above error.

Now I’m researching how to pass the authentication info to the curl command.

Any tips/suggestions ?

Thanks!

I have added an Autherization Header:

curl -H "Content-Type: application/json" -H 'Authorization: Token aws_secret_access_key=' -X POST -d '{"icecreamId":"123", "name":"chocolate"}' https://0k213z6zp2.execute-api.us-east-1.amazonaws.com/latest

But I got this error: {"message":"Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. "}

1

1 Answers

0
votes

Please Enable CORS for the API and make sure IAM is not enabled for the API. Also, this can be tested directly from API gateway itself for accuracy.