How to authenticate a Cognito user pool in node js

Using v1.10 amazon-cognito-identity-js in the next app node.

I wrote the following: This call is made after user registration confirmation and email confirmation.

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) {
 }
});

When I call authenticateUser, I get "ReferenceError: navigator not defined"

It looks like the node server is trying to invoke a browser.

I created a github problem, and the recommendation was to refer to "jsbn": "^ 0,1,0", "sjcl": "^ 1.0.3", "amazon-cognito-identity-js": "^ 1.10.0 "," aws-sdk ":" ^ 2.5.3 "

. , . nodejs-, .

NB: Cognito . , .

Source repo: https://github.com/prem911/cognito-nodejs

, " "?

+4
1
+1

Source: https://habr.com/ru/post/1665605/


All Articles