I have a web app running with its APIs all behind AWS API Gateway. It is currently authenticated using Cognito token.
Now I want to the users to be able to set up API key pairs (id and secret) so that they will have an alternative way to authenticate and access their account programmatically, similar to this (https://support.binance.com/hc/en-us/articles/360002502072-How-to-create-API).
I am aware some solutions (non-optimal IMO, please correct me if I am wrong):
What is the best way to achieve something like this (https://support.binance.com/hc/en-us/articles/360002502072-How-to-create-API) with API gateway?
I would propose implementing a request based Lambda authorizer [1]. Looking at your example, it seems you expect to enforce some customized security policies as well (i.e., IP address based check, enabling specific APIs).
[1] See the section named "Create a Lambda Function of a Lambda Authorizer of the REQUEST type" in https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html