Coder Social home page Coder Social logo

serverless-cognito-auth's Introduction

serverless-cognito-auth

Sample code for using Cognito User Pools with CUSOTOM AUTH of API Gateway.

use this resources.

  • AWS API Gateway
  • Cognito User Pools
  • Lambda functions

Cognito User Pools

create Cognito Pools

$ POOL_NAME=sample STAGE=dev sh CognitoUserPool/bin/create_cognito_user_pool.sh

delete Cognito Pools

This script using config.json, it was created from create_cognito_user_pool.sh

$ sh CognitoUserPool/bin/delete_cognito_user_pool.sh

create User

$ aws cognito-idp admin-create-user --cli-input-json file://CognitoUserPool/user.json

get token

$ aws cognito-idp admin-initiate-auth --cli-input-json file://CognitoUserPool/signIn.json

API deploy

install serverless

Please use serverless version 1.5 or more.

npm install serverless -g

or

npm upgrade serverless -g

deploy

serverless deploy

test

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!"}

License

MIT

serverless-cognito-auth's People

Contributors

ganezasan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serverless-cognito-auth's Issues

NotAuthorizedException when calling command for cognito signIn

When I call this command aws cognito-idp admin-initiate-auth --cli-input-json file://CognitoUserPool/signIn.json I get the message below.

I already changed the file signIn.json and created a App Client for User Pool.

An error occurred (NotAuthorizedException) when calling the AdminInitiateAuth operation: Unable to verify secret hash for client 74jdrobmasoi0m2i1je8vhrij6

This is how is my json signIn.json:

{ "AuthFlow": "ADMIN_NO_SRP_AUTH", "AuthParameters": { "USERNAME": "jairo", "PASSWORD": "Honda@123" }, "ClientId": "74jdrobmasoi0m2i1je8vhrij6", "UserPoolId": "us-east-1_ZQoyxbBkE" }

What I am doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.