0

I am using amazon-cognito-identity-js like so:

import {CognitoUserPool, CognitoUserAttribute, CognitoUser, AuthenticationDetails, CognitoUserSession} from 'amazon-cognito-identity-js';

        const userPool = new CognitoUserPool({
            UserPoolId : 'xxxx',
            ClientId : 'xxxxx',  
        });
        const user = new CognitoUser({
            Username: username,
            Pool: userPool,
        })
        const authenticationDetails = new AuthenticationDetails({
            Username: username,
            Password: password,
        })

        // Have also tried user.authenticateUser
        user.initiateAuth(authenticationDetails, {
            onSuccess: console.log,
            onFailure:  console.log
        })

This throws an error like NotAuthorizedException: Incorrect username or password.

Yet when I try to run the SAME user and password through @aws-sdk I have no issues. The below succedes. I have verified that the user, password, and cognito pool parameters are the exact same for both requests.

import { CognitoIdentityProvider  } from "@aws-sdk/client-cognito-identity-provider";
const client = new CognitoIdentityProvider({ region: "us-east-1" });

client.initiateAuth({
    ClientId: "xxxx",
    AuthFlow:'USER_PASSWORD_AUTH',
    AuthParameters:{
        'USERNAME': 'test@xxxx',
        'PASSWORD': 'xxxxx'
    }
}).then(console.log)

Could this be a configuration difference in my cognito deployment that I am missing?

0 Answers0