Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

461
Vistas
In AWS how do I add an API key to my API?

Hello: I've been following two tutorials in the AWS documentation:

creating the sample pet store API (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-from-example.html)

...and creating an API key (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html#api-gateway-usage-plan-create-apikey).

When I test the pet store get method with the provided URL, it returns:

Welcome to your Pet Store API You have successfully deployed your first API. You are seeing this HTML page because the GET method to the root resource of your API returns this content as a Mock integration.

The Pet Store API contains the /pets and /pets/{petId} resources. By making a GET request to /pets you can retrieve a list of Pets in your API. If you are looking for a specific pet, for example the pet with ID 1, you can make a GET request to /pets/1.

You can use a REST client such as Postman to test the POST methods in your API to create a new pet. Use the sample body below to send the POST request:

{ "type" : "cat", "price" : 123.11 }

Now I go to the API Gateway -> API -> Resources -> -> Method Request -> API Key Required and change it to "True" and redeploy.

When I go to the provided URL to test, now the page returns:

{"message":"Forbidden"}

Which makes sense... I told it API required = true, right?

So my question is, how do I pass the API key? So that I don't get the "forbidden" result? I didn't see that in the tutorial links I pasted above and haven't been able to find elsewhere.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

  1. You Create a Usage Plans
  2. Attach this usage plan to your API and Stage
  3. Create an API Key
  4. Now invoke your API with header named x-api-key and value of it is the API Key created in step-3

Sample: curl -i -H "x-api-key: Cd2YiWs8Fv8Lg6njI0wXf1iiNOE94XjM3EQe8567" -X GET https://7r9cvghbf4.execute-api.ap-northeast-2.amazonaws.com/dd/pets

over 4 years ago · Santiago Trujillo Denunciar

0

Assuming you've followed all steps for creating the API key you can use this API key by specifying it in the x-api-key header within your request.

You distribute API keys to your customers and require them to pass the API key as the X-API-Key header of each incoming request.

More information for using API keys in API Gateway is available on: Choose an API key source - Amazon API Gateway

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda