I can not connect to my app client. The following is the code I use:
const AWS = require('aws-sdk');
// AWS.config.region = 'ap-southeast-2'
AWS.config.update({ region: 'ap-southeast-2' });
try {
var params = {
AuthFlow: 'ADMIN_NO_SRP_AUTH',
ClientId: process.env.COGNITO_CLIENT_ID,
UserPoolId: process.env.COGNITO_USER_POOL_ID,
AuthParameters: {
email: "na****@*****.com",
password: "********",
}
};
console.debug("params: ", params)
//{apiVersion: '2016-04-18'}
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
const res = await cognitoidentityserviceprovider.adminInitiateAuth(params, function (err, data) {
if (err) {
console.debug("error adminInitiateAuth. params: ", params);
console.log("err: ", err);
return { props: { data } }
} else {
The output is:
err: ResourceNotFoundException: User pool client ******* does not exist
I am this close to start crying like a baby if this doesnt work
The error was telling me to check the client id.
The problem was the AWS config. It doesnt matter if I was developing in JS and using VS studio... the app was using my Windows 10 AWS credentials.
I changed the AWS.config by code and now it detects everything.
const AWS = require('aws-sdk'); AWS.config.update({ region: 'ap-southeast-2' }); AWS.config.credentials.accessKeyId = process.env.AWS_IAM_ACCESS_KEY_ID AWS.config.credentials.secretAccessKey = process.env.AWS_IAM_SECRET_ACCESS_KEY