Bird
0
0

Given this AWS SDK code snippet to authenticate a user, what will be the output if the password is incorrect?

medium📝 Predict Output Q4 of 15
AWS - Serverless Architecture
Given this AWS SDK code snippet to authenticate a user, what will be the output if the password is incorrect?
const params = {
AuthFlow: 'USER_PASSWORD_AUTH',
ClientId: 'abc123',
AuthParameters: {
USERNAME: 'user1',
PASSWORD: 'wrongpass'
}
};
cognito.initiateAuth(params, (err, data) => {
if (err) console.log(err.code);
else console.log('Success');
});
AUserNotFoundException
BSuccess
CNotAuthorizedException
DInvalidParameterException
Step-by-Step Solution
Solution:
  1. Step 1: Understand error for wrong password

    A wrong password triggers NotAuthorizedException in Cognito.
  2. Step 2: Match error code with options

    NotAuthorizedException matches the expected error; others indicate different issues.
  3. Final Answer:

    NotAuthorizedException -> Option C
  4. Quick Check:

    Wrong password error = NotAuthorizedException [OK]
Quick Trick: Wrong password returns NotAuthorizedException error [OK]
Common Mistakes:
  • Confusing user not found with wrong password error
  • Expecting success despite wrong password
  • Misreading error codes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes