如何在节点js

时间:2017-01-03 11:41:55

标签: node.js amazon-web-services 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) {
 }
});

当调用authenticateUser时,我得到“ReferenceError:导航器未定义”

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

我在此创建了一个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

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

1 个答案:

答案 0 :(得分:1)

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

AWS Cognito unauthenticated login error (window is not defined) [JS]

相关问题