Я использую AWS Cognito с Node.JS.
Я успешно регистрирую и проверяю пользователей, но Аутентификация возвращает «неизвестную ошибку, тело ответа при получении не определено».
Я использую модуль node-fetch вместе с amazon-cognito-identity-js (установите как var AWSCognito в приведенном ниже коде). Пользователь не требует смены пароля и проверен.
Испытывали ли это другие, и как вы решили проблему?
Цените любые указания заранее ....
Вот мой код, мой полный модуль находится на npm как iditawsutils:
exports.authCognitoUser = function(theUserPoolID, theClientID, userName, userPassword) {
var authenticationData = {
Username : userName,
Password : userPassword
};
var authenticationDetails = new AWSCognito.AuthenticationDetails(authenticationData);
var poolData = { UserPoolId : theUserPoolID,
ClientId : theClientID
};
var userPool = new AWSCognito.CognitoUserPool(poolData);
var userData = {
Username : userName,
Pool : userPool
};
console.log('authentication details: ',authenticationDetails);
var cognitoUser = new AWSCognito.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
console.log('id token + ' + result.getIdToken().getJwtToken());
console.log('refresh token + ' + result.getRefreshToken().getToken());
return result;
},
onFailure: function(err) {
console.log(err.message || JSON.stringify(err));
return err;
},
});
}
// из журнала консоли:
authentication details: AuthenticationDetails {
validationData: {},
authParameters: {},
username: 'thesmarterstuff',
password: 'passW0rd!’ }
Неизвестная ошибка, тело ответа от fetch: undefined