Using AWS cognito from plain JavaScript

别说谁变了你拦得住时间么 提交于 2019-12-11 00:16:08

问题


Hoping someone can shed some light on using Cognito with plain JavaScript. No npm, no webpack, just plain JavaScript. I found a post that had a great example including the required AWS JavaScript libraries. I worked from this example until I ran into the problem of sign out not working. I thought perhaps the libraries in the example were out of date so I went looking for the latest. This is where things got confusing. In the example I had the following JavaScript libraries - amazon-cognito-identity.min.js, aws-cognito-sdk.min.js, and aws-sdk.min.js. I assume that aws-cognito-sdk must no longer exist? I updated the other two and see that there is an amazon-cognito-auth library. Do I need that? Anyhow with those three libraries the existing code no longer functions. I end up with errors like "AWSCognito is undefined" etc.

Hoping someone can point me in the right direction and show me where the downloads, documentation, etc for using Cognito in plain JavaScript are


回答1:


Find hereunder a template I created for myself to work from. It is in "plain javascript" and in an angularjs app.

My template: https://github.com/PouncingPoodle/aws-cognito-angularjs/tree/master based on: https://github.com/takanorig/aws-cognito-angularjs

Always make sure that you use the correct versions of scripts and the correlating apiVersion when you call a Lambda function for example

There might be bad practice involved but as far as I could research it should be all fine.



来源:https://stackoverflow.com/questions/56246115/using-aws-cognito-from-plain-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!