0 votes
1 view
in AWS by (16.7k points)

I am trying to call adminInitiateAuth as follows:

var params = {

        AuthFlow: 'ADMIN_NO_SRP_AUTH',

        ClientId: 'xxxxxxxxx',

        UserPoolId: 'eu-west-1_xxxxxx',

        AuthParameters: {

            email: email,

            password: password

        }

    };

    var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({apiVersion: '2016-04-18'});

    cognitoidentityserviceprovider.adminInitiateAuth(params, function(err, data) {

      if (err) {

            console.log(err, err.stack);

        } else {

            console.log(data);

        }

    });

But I am getting the following error:

TypeError: cognitoidentityserviceprovider.adminInitiateAuth is not a function

Any ideas what I am doing wrong here? Other functions such as signUp work when called in the same manner!

1 Answer

0 votes
by (39.6k points)

Check your version of NodeJS AWS SDK which is running on your Lambda function. Most probably it would be version 2.4.9.

console.log('SDK Version is ' + AWS.VERSION)

adminInitiateAuth was released with the version 2.4.11, so try adding the sdk manually:

npm install aws-sdk

Then you can Zip up your Lambda function file with the node_modules directory

...