I am looking to wrap a third party resource, to expose it without the access token that is sent as a query parameter.
For this reason, I thought I could use the API gateway.
I found how to have mapped path and query parameters, which are proxyed from the request itself.
But is it possible to somehow hardcode the access token inside the API gateway, to be passed onto the destination, so the users won't have to include it in their request?
Or my only option is to make a Lambda for this purpose...?
I used terraform to create these kind of resources. here is an example of a api integration using terraform:
resource "aws_api_gateway_integration" "api_store_get_integration" {
rest_api_id = "${aws_api_gateway_rest_api.service_api.id}"
resource_id = "${aws_api_gateway_resource.store.id}"
http_method = "${aws_api_gateway_method.store_get.http_method}"
integration_http_method = "GET"
type = "HTTP_PROXY"
uri = "${var.yext_base_url}entities"
passthrough_behavior = "WHEN_NO_MATCH"
request_parameters = {
"integration.request.header.api-key" = "'${var.yext_api_key}'",
"integration.request.header.content-type" = "'application/json'",
"integration.request.querystring.filter" = "method.request.querystring.filter",
"integration.request.querystring.v" = "'20191001'"
}
}
explaining it:
api-key header to the request with a variable passed to terraformcontent-type header to the request with a static valuev with the static value '20191001'If you don't know about terraform, it is a tool that reads this document and send requests to AWS to create the resources in the way that you defined them. In the case of the snippet above, terraform will receive two variables vat.yext_base_url and var.yext_api_key, will concatenate their values in the configuration and create the resources in AWS.
I don't know what you're using, but in your case you will need to find the place to change the configurations for the integration request. Try to research a little and if you don't find it I can guide you again based on your deployment model.
Don't know if you ever solved this, but for anyone coming across this question, you can do this in the console if you enter the static value in single quotes:

The quotes are removed from the parameter when the integration request is made.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With