You have created a Cognito user pool for your API named myLambda in the Amazon API Gateway console.
Answers
Answer:
As per the data given in the above question.
There are two ways to set up an Amazon Cognito user pool as an authorizer on an API Gateway REST API:
- There are two ways to set up an Amazon Cognito user pool as an authorizer on an API Gateway REST API:Create a COGNITO_USER_POOLS authorizer.
- There are two ways to set up an Amazon Cognito user pool as an authorizer on an API Gateway REST API:Create a COGNITO_USER_POOLS authorizer.Create an AWS Lambda authorizer.
For authorization, you can use either ID tokens or access tokens. For more information, see Using tokens with user pools.
- Resolution
The following procedure shows how to create a COGNITO_USER_POOLS authorizer. The example assumes you already created two things:
- An Amazon Cognito user pool with an app client.
- An API Gateway REST API resource.
- Create a COGNITO_USER_POOLS authorizer
- For more information, see Integrate a REST API with an Amazon Cognito user pool.
Test the new COGNITO_USER_POOLS authorizer
Test the new COGNITO_USER_POOLS authorizerAfter you create the COGNITO_USER_POOLS authorizer, do the following:
1. In the API Gateway console, choose the Test button under the new authorizer.
2. In the Test window, for Authorization, enter an ID token from the new Amazon Cognito user pool.
3. Choose Test.
Note: If the ID token is correct, the test returns a 200 response code. Incorrect ID tokens return a 401 response code.
#Configure the COGNITO_USER_POOLS authorizer on an API method
- #NoteFor more information, see the To configure a COGNITO_USER_POOLS authorizer on methods section of Integrate a REST API with an Amazon
- Cognito user pool.
- Get authorization tokens
There are four ways to get authorization tokens:
- The hosted web UI for Amazon Cognito
- The AWS Command Line Interface (AWS CLI).
- One of the AWS SDKs.
- The Postman app.