Giter Club home page Giter Club logo

aws-cognito-js-example's Introduction

aws-cognito-js-example

Example javascript application that uses AWS Cognito to:

  • add a new user to the pool
  • sign the user in
  • sign the user out
  • change password
  • reset forgotten password
  • delete the user

Motivation

Examples provided in the AWS Cognito Developer Guide are not always easy to follow. This minimalistic application was created to fill this gap.

Prerequisites

It is recommended that you create a new Cognito User pool for this example application. If you are new to Cognito you might want to check AWS "Getting Started" guide.

While creating the user pool make sure you:

  1. Enable signing in with a user name ("Users can use a username and optionally multiple alternatives to sign up and sign in"). Check the box to "Also allow sign in with verified email address"
  2. Select email and preffered_username as required attributes
  3. Check "Allow users to sign themselves up" on the policies page
  4. When asked "Do you want to require verification of emails or phone numbers?" select Email
  5. Disable advanced security features
  6. Choose "code" as user verification method
  7. Create an application that can access this user pool. IMPORTANT: disable application secrets. Javascript API does not support client secrets.
  8. Copy your Pool ID and Application ID - you will need to provide them to our application.

Dependencies

  1. amazon-cognito-identity.min.js is included in the repository. It is now part of AWS Amplify Javascript SDK.
  2. bootstrap (requires jQuery) for the UI.

Code

There are three files in the project:

  • index.html
  • js/authentication.js is a thin wrapper for the SDK that makes using it a bit easier
  • js/user-interface.js contains page rendering code, DOM event handlers etc.

How to use

Clone the repo and open index.html in the browser. The code is tested on Chrome and Firefox. Click Credentials in the navigation bar and provide your user pool ID and app ID. They are stored in the browser local storage and will persist, so you might want to clear your secrets ("Forget" button) when you're done using it.

You might need a disposable email service like Guerilla Mail or similar to create new users.

Credits

Icons by Julian Schnaars

aws-cognito-js-example's People

Contributors

romankosobrodov avatar

Watchers

James Cloos avatar

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.