Skip to content

gravitybacklight/aws-cognito-barebones-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-cognito-barebones-js

basic aws cognito and javascript example

No jquery, just a basic html form, javascript and amazon-cognito-identity.min.js.

Bit of duplication in the code, but this allows you to walkthrough what is happening.

Getting started

Assuming you have an AWS account, you need to create a cognito user pool. The pool is configured to allow email login also.

  1. Create user pool
  2. Give it a name and select "step through settings"
  3. Leave Username radio button selected and also tick "Also allow sign in with verified email address" beheath it
  4. Tick the required tickbox against "preferred username"
  5. Choose a password policy, leave "Allow users to sign themselves up" selected
  6. Leave MFA & verifications as defaults
  7. If preferred, choose an SES region closer to you, leave the rest as default for now
  8. Add tags if you want
  9. Leave "Do you want to remember your user's devices" as default
  10. Click "Add an app client"
  11. Give app client a name, untick "Generate client secret"
  12. Click "Create app client", then click "next step"
  13. Click through Triggers & Review & click "Create pool"

Configuration

  1. Within your user pool under "General Settings", copy the "Pool Id"
  2. Under "App clients", copy the "App client id"
  3. Paste both of these values into user.js into the placeholders under the getPoolData function

Test

You should now be able to run load all 3 html files locally and successfully communicate with cognito. Use your browsers developer tools to see the console whilst you test as all output goes there.

  • register.html = create a user within your userpool and it will sent you a verification code via email
  • verify.html = the emailed verification code can be entered with your username
  • login.html = your username/email and password are used here, the console will show your access token

Thanks

(https://github.com/RomanKosobrodov/aws-cognito-js-example) - Gave a brilliant kickstart in figuring out where i was going wrong with my testing

About

basic aws cognito and javascript example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published