This error has probably occurred because you might not have enabled the following checkboxes while configuring the App client in Cognito User Pool.
- “Enable username password auth for admin APIs for authentication (ALLOW_ADMIN_USER_PASSWORD_AUTH)”checkbox.
- “Enable username password-based authentication (ALLOW_USER_PASSWORD_AUTH)” checkbox.