Iain MacCormick
Iain MacCormick

Reputation: 317

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

Upvotes: 13

Views: 40738

Answers (7)

Rajani Upadhyay
Rajani Upadhyay

Reputation: 1

In my case i was using correct url only, https://{api-id}.execute-api.{region}.amazonaws.com/{stage}/{resource} But as i had configured GET method in API gateway,and i was trying POST method from Postman i was getting Authentication error, please do check this also.

Upvotes: 0

Wesley Cheek
Wesley Cheek

Reputation: 1706

I saw this message while configuring Step Functions to do an apigateway:invoke task.

Make sure to specify AuthType: IAM_ROLE in the task definition. For an example, see here.

Upvotes: 0

raido
raido

Reputation: 13

Another reason is when a deployment is created before the method, so the stage does not contain the method although the API does. Do not forget to add the dependencies for the deployment.

Upvotes: 1

Feng Zhang
Feng Zhang

Reputation: 1960

In my case, the url isn't the correct one. From Aws APIs, goto your api, goto the "stages" your method, find the "invoke URL", then use it in postman.

Upvotes: 1

evgeni tsvetanov
evgeni tsvetanov

Reputation: 181

Another potential reason is an error being thrown by the Lambda function code. I had a similar issue and it turned out to be a TypeError in my python code. You can check CloudWatch logs to gain more information.

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1075317

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.

Upvotes: 15

Paradigm
Paradigm

Reputation: 2026

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.

Upvotes: 19

Related Questions