Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway {"message":"Missing Authentication Token"}

I am using API Gateway to build a REST API to communicate with a deployed aws sagemaker model via aws lambda. When I test the Method (Method Test Results) my lambda function returns the required results. I've definitely deployed the API and I'm using the correct invoke URL with the resource name appended (Method Invoke URL). Finally I have checked all the auth settings for this method request (Method Auth Settings). When I input the invoke URL into the browser or try to call the REST API (from cloud9 IDE -- a web app I am developing) I get this error: {"message":"Missing Authentication Token"} (URL Response)

My API is very simple, only one POST request, it does not contain any other resources or methods. I tried also setting up the method under '/' but had the same issue.

There are a lot of people out there with this issue, and I've spent a while reading through similar posts - but the solutions boil down to the issues I've checked above. If anyone could help it would be greatly appreciated!

Iain

like image 457
Iain MacCormick Avatar asked May 31 '20 10:05

Iain MacCormick


People also ask

What does missing authentication token mean?

Short description. API Gateway REST API endpoints return Missing Authentication Token errors for two reasons: The API request is made to a method or resource that doesn't exist. The API request isn't signed when the API method has AWS Identity and Access Management (IAM) authentication turned on.

Why do I get an HTTP 403 Forbidden error when connecting to my API gateway APIs from a VPC?

The HTTP 403 Forbidden error most commonly occurs when private DNS is enabled for an API Gateway interface VPC endpoint that's associated with a VPC. In this scenario, all requests from the VPC to API Gateway APIs resolve to that interface VPC endpoint.


Video Answer


2 Answers

For the benefit of anyone else who's as silly as I am, the other reason you may get this error is that you're requesting a URL that isn't configured.

For instance, you've set up a proxy API on / that sends requests through to your backend, and the path to that is https://mumblemumble/prod, and you request https://mumblemumble/prod itself instead of https://mumblemumble/prod/your/resource, you'll get this error.

like image 83
T.J. Crowder Avatar answered Nov 14 '22 23:11

T.J. Crowder


You have configured the API Gateway resource with the POST method and when using the API Gateway console to test, the console handles setting the HTTP method to POST. However, when you directly hit the invoke URL from the browser, the GET method is used.

API Gateway by default returns the {"message":"Missing Authentication Token"} response for methods not defined or for paths not present, as given here

If API Gateway fails to process an incoming request, it returns to the client an error response without forwarding the request to the integration backend. By default, the error response contains a short descriptive error message. For example, if you attempt to call an operation on an undefined API resource, you receive an error response with the { "message": "Missing Authentication Token" } message.

Use the POST method to test your API. This can be done using the command-line (curl) or using Postman.

like image 40
Paradigm Avatar answered Nov 15 '22 00:11

Paradigm