Skip to content

Instantly share code, notes, and snippets.

@nicc777
Created May 30, 2022 05:28
Show Gist options
  • Save nicc777/32b8a3b6873e53fe8f97c76f0045f346 to your computer and use it in GitHub Desktop.
Save nicc777/32b8a3b6873e53fe8f97c76f0045f346 to your computer and use it in GitHub Desktop.
Getting the AWS Cognito JavaScript LIbrary (Steps)

Use Case

These steps demonstrate how to get the JavaScript library for AWS Cognito integration when using simple HTML and JavaScript - no frameworks like ReactJS, or other Node type projects.

Prerequisites

Even though you may not want to use a framework, you still require a relatively new stable version of nodejs

My approach:

  • Download the Linux tar.gz file
  • Unzip in ~/opt/apps
  • In ~/.zshrc create a symlink to the binary directory, for example: export PATH=$PATH:~/opt/apps/node-v16.15.0-linux-x64/bin
  • For the installation to take effect, just source the script again or open a new terminal

Obtain and use Cognito JavaScript file

In this example, I have my plain HTML and JavaScript files in ~/tmp/poc

Steps:

  • Create a temporary directory to install Amplify Package: mkdir ~/tmp/node-temp and change into this directory
  • Run: npm i amazon-cognito-identity-js
  • Copy the required file to the working source directory: cp -vf node_modules/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js ~/tmp/poc/

And that is all that is required. You can now use the library. Some useful example can be found in the Amplify Project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment