gpt4 book ai didi

javascript - AWS Cognito 身份 NotAuthorizedException

转载 作者:行者123 更新时间:2023-12-03 09:42:26 30 4
gpt4 key购买 nike

我正在使用 AWS javascript sdk 将用户池与我正在构建的 Web 应用程序集成。用户池已设置,我已按照此处的用法示例进行操作:https://github.com/aws/amazon-cognito-identity-js

我不断收到一条错误消息:“NotAuthorizedException:无法验证客户端的 secret 哈希(我的应用程序客户端 ID)”

AWS.config.region = 'us-east-1'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: '...' // my identity pool id here
});


AWSCognito.config.region = 'us-east-1';
AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: '...' // my identity pool id here
})


var poolData = {
UserPoolId: '...', // my user pool id here
ClientId: '...' // client id here
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);

var userData = {
Username : 'username',
Pool : userPool
};

var attributeList = [];

var dataEmail = {
Name : 'email',
Value : 'email@mydomain.com'
};
var dataPhoneNumber = {
Name : 'phone_number',
Value : '+15555555555'
};
var attributeEmail = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataEmail);
var attributePhoneNumber = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataPhoneNumber);

attributeList.push(attributeEmail);
attributeList.push(attributePhoneNumber);

userPool.signUp('username', 'password', attributeList, null, function(err, result){
if (err) {
alert(err);
return;
}
cognitoUser = result.user;
console.log('user name is ' + cognitoUser.getUsername());
});

以上代码片段有任何建议或潜在问题吗?谢谢!

最佳答案

这个问题的解决方案实际上非常简单。您必须在 aws 中删除该应用程序,然后在没有 key 的情况下重新添加它,以便它可以授权。

关于javascript - AWS Cognito 身份 NotAuthorizedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37603822/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com