Currently I am developing a custom login flow for some of my projects, using AWS Cognito.
Recently I achieved the login using username and password, as follows:
const data: CognitoIdentityServiceProvider.Types.AdminInitiateAuthRequest = {
UserPoolId,
AuthFlow: "ADMIN_USER_PASSWORD_AUTH",
ClientId: CognitoConfig.ClientId,
AuthParameters: {
USERNAME: username,
PASSWORD: password,
// SECRET_HASH: hash,
}
};
Is it possible to login using email+password using CognitoIdentityServiceProvider.adminInitiateAuth?
Ive tried to replace USERNAME with EMAIL (and the respective field value), but I got an InvalidParameterException, expecting USERNAME to be forwarded.
Try to pass the email in USERNAME attribute, Also set the AuthFlow to "ADMIN_NO_SRP_AUTH"
const data: CognitoIdentityServiceProvider.Types.AdminInitiateAuthRequest = {
UserPoolId,
AuthFlow: "ADMIN_NO_SRP_AUTH",
ClientId: CognitoConfig.ClientId,
AuthParameters: {
USERNAME: '[email protected]',
PASSWORD: password,
// SECRET_HASH: hash,
}
};
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With