I am using in Node.js the following versions
"amazon-cognito-identity-js": "^2.0.29",
"node-fetch": "^2.2.0",
I am trying to signUp and authenticateUser in my app.
Initially I was getting "fetch undefined" when I call singUp. Which was fixed by adding the node-fetch library. Now I can successfully signUp users.
Now I am getting the error "Unknown error, the response body from fetch is: undefined" when I call authenticateUser method. The code is as following.
`app.post('/login', (req, res) => {
var authenticationData = {
Username: req.body.email,
Password: req.body.password,
};
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var userData = {
Username: req.body.email,
Pool: userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
var accessToken = result.getAccessToken().getJwtToken();
/* Use the idToken for Logins Map when Federating User Pools with identity pools or when passing through an Authorization Header to an API Gateway Authorizer*/
var idToken = result.idToken.jwtToken;
},
onFailure: function (err) {
console.log(err);
}
});`
I am in the same issue
I am using in Node.js the following versions
"amazon-cognito-identity-js": "^2.0.29",
"node-fetch": "^2.2.0",I am trying to signUp and authenticateUser in my app.
Initially I was getting "fetch undefined" when I call singUp. Which was fixed by adding the node-fetch library. Now I can successfully signUp users.
Now I am getting the error "Unknown error, the response body from fetch is: undefined" when I call authenticateUser method. The code is as following.
`app.post('/login', (req, res) => {
var authenticationData = {
Username: req.body.email,
Password: req.body.password,
};var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData); var userData = { Username: req.body.email, Pool: userPool }; var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); cognitoUser.authenticateUser(authenticationDetails, { onSuccess: function (result) { var accessToken = result.getAccessToken().getJwtToken(); /* Use the idToken for Logins Map when Federating User Pools with identity pools or when passing through an Authorization Header to an API Gateway Authorizer*/ var idToken = result.idToken.jwtToken; }, onFailure: function (err) { console.log(err); } });`
@isamsamet Try adding this within the authenticate user function and use the log to to see what is needing defined:
mfaSetup: function(challengeName, challengeParameters) {
console.log('mfaSetup');
},
// @ts-ignore
associateSecretCode : function(secretCode) {
console.log('associateSecretCode');
},
selectMFAType : function(challengeName, challengeParameters) {
console.log('selectMFAType');
},
totpRequired : function(secretCode) {
console.log('totpRequired');
},
mfaRequired: function (codeDeliveryDetails) {
console.log('mfaRequired');
}
Some of these will be required depending on the User Pool configuration. Have a look at use case 23 and 27 for how these blocks should be configured. Use cases here.
I removed the remember device and set it to no. It worked.
I removed the remember device and set it to no. It worked.
working
Closing the issue as you will no longer receive unknown error in the latest version.
Most helpful comment
I removed the remember device and set it to no. It worked.