I’m trying to authenticate a user with AWS Cognito using the USER_PASSWORD_AUTH flow in JavaScript. However, the response from initiateAuth is always empty. Here’s the code I’m using:
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({region: 'eu-central-1'});
const poolData = {
UserPoolId: "userPoolId",
ClientId: "clientId",
}
let username = document.getElementById('username').value;
let password = document.getElementById('password').value;
var aws_params = {
AuthFlow: "USER_PASSWORD_AUTH",
AuthParameters: {
"PASSWORD": password,
"SECRET_HASH": "secretHash",
"USERNAME": username
},
ClientId: "clientId",
};
response = cognitoidentityserviceprovider.initiateAuth(aws_params);
However, the response object is consistently empty, like this:
{
"request": {…},
"data": null,
"error": null,
"retryCount": 0,
"redirectCount": 0,
"httpResponse": {…},
"maxRetries": 3,
"maxRedirects": 10
}
I did the same thing but using a django view and it works: i got the token from cognito. But in js I’m stuck.
Any guidance is appreciated!