javascript – AWS Cognito无法验证客户端的秘密哈希值

前端之家收集整理的这篇文章主要介绍了javascript – AWS Cognito无法验证客户端的秘密哈希值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试验证用户时,我得到了

错误:无法验证客户端的密钥哈希< CLIENT_ID_HERE>

怎么了?我的代码如下:

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上,客户端密钥已被禁用

解决方法

适用于JavaScript的Amazon Cognito Identity SDK不支持具有客户端密钥的应用程序.这在 SDK documentation中说明:

When creating the App,the generate client secret Box must be
unchecked because the JavaScript SDK doesn’t support apps that have a
client secret.

看起来您将不得不重新配置您的应用程序.

猜你在找的JavaScript相关文章