Amazon Cognito Bower Gotchas

Over the week I tried to hook my angularjs site up to Amazon’s Cognito service. It all seemed straight forward. However, I learned of a gotcha. Behind the scenes I am using bower to install javascript dependencies and gulp to serve the site locally and build the site. As I was using this combination, i did a bower install amazon-cognito-identity-js --save . Normally this would work correctly (I assume). However, I encountered that it did not create a bower.json file in its root directory and shoved all of its scripts into a dist directory. That’s all fine, but my gulp setup is expecting a bower.json in the root. If anyone cares, or has encounted this issue, below is my bower.json file and I moved the javascript files from dist to the amazon-cognito-identity-js root.


{
"name": "amazon-cognito-identity-js",
"version": "1.16.0",
"main": [
"./aws-cognito-sdk.js",
"./amazon-cognito-identity.min.js"
],
"ignore": [],
"dependencies": {
}
}

One more site point. The order of the javascripts DOES matter. If the aws-cognito-sdk is loaded AFTER the amazon-cognito-identity you will receive AWSCognito is not a found or AWSCognito is not a factory errors.

Leave a Reply

Your email address will not be published. Required fields are marked *