Sample code for using Cognito User Pools with CUSOTOM AUTH of API Gateway.
use this resources.
- AWS API Gateway
- Cognito User Pools
- Lambda functions
$ POOL_NAME=sample STAGE=dev sh CognitoUserPool/bin/create_cognito_user_pool.sh
This script using config.json, it was created from create_cognito_user_pool.sh
$ sh CognitoUserPool/bin/delete_cognito_user_pool.sh
$ aws cognito-idp admin-create-user --cli-input-json file://CognitoUserPool/user.json
$ aws cognito-idp admin-initiate-auth --cli-input-json file://CognitoUserPool/signIn.json
Please use serverless version 1.5 or more.
npm install serverless -g
or
npm upgrade serverless -g
serverless deploy
Please change <apiId>
and <IdToken>
.
curl -X POST https://<apiId>.execute-api.ap-northeast-1.amazonaws.com/dev/auth/hello -H "Authorization: <IdToken>
> {"Message":"Hello World!"}
MIT