简体   繁体   中英

Getting error: Missing Authentication Token after AWS API request

I am trying to call a Lambda Function through AWS API Gateway.

I've been getting this error when I tried IAM authentication, API Key Authentication and also with no authentication. 在此处输入图像描述

{"message":"Missing Authentication Token"}

Some people had the same problem due to non existing endpoint. However, I've taken my endpoint directly from the Lambda Function AWS Console. 在此处输入图像描述

I've been trying to open the URL in the Browser and also on the Postman (with and without a header authentication: x-api-key: *****************). 在此处输入图像描述

Both responded with above stated error.

One more step: in Postman, you need to set the Authorization to AWS Signature , and then enter your AccessKey and SecretKey from your IAM user:

Postman screenshot邮递员截图

I'll write up a detailed FAQ here for any viewers. Ordered by most common cause.

  1. Incorrect resource path and/or HTTP method.
    • If you have the right resource path and the wrong HTTP method, you'll still see this message
    • You can use Postman or some other client to sign a request to the same resource/method and if you get a 404 then you definitely have the wrong resource/method .
  2. Missing signature on protected resource/method. By default, your API will be open. If you have explicitly required AWS Auth then the error indicates that the request wasn't signed.
  3. If you're using the Lambda console to create an 'API Endpoint' it may be an issue on the Lambda end, or a delay in the propagation of the new API. In this case go to the API Gateway console and you should see the same API that Lambda created for you. Make sure it has been deployed and you have the right stage, resource path, and method .

Just wanted to mention that if you set your API gateway's authentication to be NONE , make sure you need to Deploy API first before the no authentication setting is in effect.

You have to Enable CORS from the actions for the API. This will create a new OPTIONS method. CORS is for cross domain requests

You need to set Api Key Required to true. See more here: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM