I'm trying to sign in from my REACT app but I receive following error from AWS cognito,
Client XXX is configured for secret but secret was not received
import { CognitoUser, AuthenticationDetails } from "amazon-cognito-identity-js"
import Userpool from "../Userpool";
const user = new CognitoUser({
Username: email,
Pool: Userpool
});
const authDetails = new AuthenticationDetails({
Username: email,
Password: password,
})
user.authenticateUser(authDetails, {
onSuccess: (data) => {
console.log('onSuccess', data);
},
onFailure(err) {
console.log('onFailure', err);
},
})
Userpool.js
import { CognitoUserPool } from 'amazon-cognito-identity-js';
const poolData = {
UserPoolId: 'XXX',
ClientId: 'XXX',
}
export default new CognitoUserPool(poolData);
I know if I disable Generate Secret Client feature in AWS congito, it should work.
But I want to know if there is any way I can pass secretHash with above code.
I have this function which will generate secretHash but don't know where and how to pass.
generateHash(username) {
return Base64.stringify(CryptoJS.HmacSHA256(username + this.clientId, this.secretHash));
}