I want to use adminInitiateAuth to trigger User Migration lambda function, but my code gives me below error:
"errorType": "UserLambdaValidationException",
"errorMessage": "PreAuthentication failed with error Bad triggerSource PreAuthentication_Authentication.",
"trace": [
"UserLambdaValidationException: PreAuthentication failed with error Bad triggerSource PreAuthentication_Authentication.",
Code is as below:
const AWS = require('aws-sdk')
const cognito = new AWS.CognitoIdentityServiceProvider()
const params = {
AuthFlow: "ADMIN_NO_SRP_AUTH",
UserPoolId: 'eu-west-2_1111111',
ClientId: '722222222222',
AuthParameters: {
USERNAME: email,
PASSWORD: password
}
}
const response = await cognito.adminInitiateAuth(params).promise();
This code works fine for another user pool in the same account.