如何在节点js中验证Cognito用户池

pre*_*911 6 amazon-web-services node.js aws-cognito

在以下nodeapp中使用amazon-cognito-identity-js的v1.10.

我写了以下内容:此通话是在用户注册确认并且电子邮件已经过验证后进行的.

var AWS = require('aws-sdk');
var AWSCognito = require('amazon-cognito-identity-js');

router.post('/emailsignin', function(req, res, next) {
var email = req.body.email;
var pwd = req.body.password;

AWS.config.region = 'eu-west-1';
var poolData = {
  UserPoolId : AWS_USERPOOLID,
  ClientId : AWS_APPCLIENTID
};
var userPool = new AWS.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var authenticationData = {
  Username : email,
  Password : pwd,
};
var authenticationDetails = new AWS.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var userData = {
  Username : email,
  Pool : userPool
};
var cognitoUser = new AWS.CognitoIdentityServiceProvider.CognitoUser(userData);

cognitoUser.authenticateUser(authenticationDetails, {
  onSuccess: function (result) {
  },
  onFailure: function(err) {
 }
});
Run Code Online (Sandbox Code Playgroud)

调用authenticateUser时,我得到"ReferenceError:navigator未定义"

看起来在节点服务器内尝试浏览器调用.

我在此创建了一个github问题,建议是引用"jsbn":"^ 0.1.0","sjcl":"^ 1.0.3","amazon-cognito-identity-js":"^ 1.10 .0","aws-sdk":"^ 2.5.3"

我对包版本进行了更改.不幸的是它也不适用于此.我创建了一个示例nodejs应用程序,它尝试使用电子邮件ID和密码进行身份验证.

注意:Cognito池设置为使用电子邮件作为别名.用户已创建,确认并通过电子邮件验证.

来源回购:https://github.com/prem911/cognito-nodejs

有关如何解决"未找到导航器"的任何指示?

Tom*_*sek 1

为了节省一些谷歌搜索时间,在撰写本文时,上述错误尚未修复,但有一个解决方法:

AWS Cognito未经身份验证的登录错误(窗口未定义)[JS]