AWS Cognito Failed to Validate Secret Hash for Client

When I try authenticateUser , I get

Error: Unable to verify secret hash for client <CLIENT_ID_HERE>

What's wrong? My code is below:

 import { Config, CognitoIdentityCredentials } from "aws-sdk" import { CognitoUserPool, CognitoUserAttribute, AuthenticationDetails, CognitoUser } from "amazon-cognito-identity-js" Config.region = "ap-northeast-2" var userpool = new CognitoUserPool({ UserPoolId: "ap-northeast-2_QosOiWMkd", ClientId: "1bd6s9mv98bo2lucen2vesbqls" }) var userData = { Username: " jiewmeng@gmail.com ", Pool: userpool } var authData = new AuthenticationDetails({ Username: " jiewmeng@gmail.com ", Password: " P@ $$w0rd" }) var cognitoUser = new CognitoUser(userData) cognitoUser.authenticateUser(authData, { onSuccess: function (result) { console.log("authenticated with", result) }, onFailure: function (err) { console.error(err) } }) 

AWS has already disabled client secret

enter image description here

+5
source share
1 answer

The Amazon Cognito Identity SDK for JavaScript does not support applications with client privacy. This is stated in the SDK documentation :

When creating an application, the client key generation section must be unchecked because the JavaScript SDK does not support applications that have a client secret.

It looks like you will have to reconfigure your application.

+9
source

Source: https://habr.com/ru/post/1267229/


All Articles