从纯JavaScript使用AWS Cognito [英] Using AWS cognito from plain JavaScript

查看:283
本文介绍了从纯JavaScript使用AWS Cognito的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以将Cognito与纯JavaScript结合使用。没有npm,没有webpack,只有普通的JavaScript。我发现有一个很好的示例的帖子,其中包含必需的AWS JavaScript库。我从这个示例开始工作,直到遇到退出不工作的问题。我认为示例中的库可能已过时,所以我一直在寻找最新的库。这就是令人困惑的地方。在示例中,我具有以下JavaScript库-amazon-cognito-identity.min.js,aws-cognito-sdk.min.js和aws-sdk.min.js。我假设aws-cognito-sdk不再存在了?我更新了其他两个,然后看到有一个amazon-cognito-auth库。我需要那个吗?无论如何,使用这三个库,现有代码将不再起作用。我最终遇到诸如未定义AWSCognito之类的错误。

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.

希望有人可以指出正确的方向,并向我展示使用Cognito的下载,文档等在哪里在普通JavaScript中是

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

推荐答案

在下面找到我创建的供自己使用的模板。它在普通javascript和angularjs应用程序中。

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

我的模板: https://github.com/PouncingPoodle/aws-cognito-angularjs/tree/master
基于: https://github.com/takanorig/aws-cognito-angularjs

例如,当您调用Lambda函数时,请始终确保使用正确版本的脚本和相关的apiVersion

可能涉及不良做法,但就我所研究的情况来看,应该没问题。

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

这篇关于从纯JavaScript使用AWS Cognito的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆