Create Cognito User Pool
Navigate to Cognito.
- Click on Manage User Pools button in the Home Page.
- Click on Create a user pool button.
- Provide a pool name as you wish. E.g., DevUserPool
- Create with default settings
- Create a App Client
- Under Review tab, click on Create pool button
Once user pool is created. Create resource server.
Resource server
Navigate to App Integration -> Resource servers.
Provide some values to Resource server Name, Identifier and Scopes.
For example,
Configure App Client Settings
Navigate to App Integration -> App client settings
- Enable Cognito User Pool check box
- Move to OAuth 2.0 section
- Under Allowed OAuth Flows, enable Client credentials check box.
- Also enable the newly created scope under Allowed Custom Scopes .
For example,
Create Domain Name
Navigate to App integration -> Domain name
Enter some domain name and check on the availability. On success, save changes.
Integrate Cognito into API Gateway
Navigate to API Gateway service.
- Move into your API Gateway.
- Click on Authorizers section
- Click on Create New Authorizer button
- New authorizer panel will be created for you.
- Choose Type as Cognito.
- Under Cognito User Pool, select the newly created user pool.
- Type Authorization under Token source text box.
- Click on Create
By now, new authorizer would have been created like below.
Attach authorizer to API resources
Move to respective resource and method where you want to enable authorization.
E.g.,
Click on Method Request from the left side panel and under Settings -> Authorization, select the newly created authorizer.
Repeat the above step for all resource methods in your API. Once done, deploy the API to get the changes reflected.
Comments
Post a Comment