use*_*080 2 javascript amazon-web-services amazon-cognito
我正在使用AWS javascript sdk将用户池与我正在构建的Web应用程序集成.用户池已设置完毕,我已按照此处的用法示例进行操作:https://github.com/aws/amazon-cognito-identity-js
我一直收到一条错误消息:"NotAuthorizedException:无法验证客户端的秘密哈希值(我的应用客户端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());
});
Run Code Online (Sandbox Code Playgroud)
上面的代码段有任何建议或潜在问题吗?谢谢!
| 归档时间: |
|
| 查看次数: |
5409 次 |
| 最近记录: |