Synchronization AWS cognito同步管理器错误同步到云
我有一个javascript客户端来执行aws cognito认证的登录,并与提供商(Facebook、Google、Twitter等)进行了验证。我可以看出,已成功从以下位置获取凭据:Synchronization AWS cognito同步管理器错误同步到云,synchronization,amazon-cognito,Synchronization,Amazon Cognito,我有一个javascript客户端来执行aws cognito认证的登录,并与提供商(Facebook、Google、Twitter等)进行了验证。我可以看出,已成功从以下位置获取凭据: var cognitoParam = { 'IdentityPoolId': 'ap-northeast-1:c8250ce6-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'RoleArn': 'arn:aws:iam::xxxxxxxxxxxx:role/roleName' 'L
var cognitoParam = {
'IdentityPoolId': 'ap-northeast-1:c8250ce6-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'RoleArn': 'arn:aws:iam::xxxxxxxxxxxx:role/roleName'
'Logins': {
'accounts.google.com': response.detail.id_token
}
};
var cognitoCred = new AWS.CognitoIdentityCredentials(cognitoParam);
它返回对象的所有凭据。我还检查了AWS控制台,池ID已在联邦身份池中列出/记录为提供者的身份验证登录
获取凭据后,我想与Cognito Sync Manager合作,将多个用户信息存储到云:
var syncManager = new AWS.CognitoSyncManager();
syncManager.openOrCreateDataset('profileSet', function(err, dataset) {
// dataset.get
// dataset.put
// dataset.remove
});
所有方法(get、put、remove)都工作得很好,但我在运行方法同步时遇到了一个问题。在示例中,放置新数据集后:
dataset.put("keyTes", "english", function(err,record){
if(!err){
dataset.synchronize({
onSuccess: function(dataset, newRecords) {
console.log(newRecords);
},
onFailure: function(err) {
console.log("Error while synchronizing data to the cloud: " + err);
}
});
}
});
它显示错误:
将数据同步到云时出错:AccessDeniedException:
用户:
arn:aws:sts::XXXXXXXXXXXXX:假定角色/roleName/web标识
未被授权在资源上执行:cognito sync:ListRecords:
arn:aws:cognito同步:ap-northeast-1:xxxxxxxxxxxx:identitypool/ap-northeast-1:c8250ce6-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxx/identity/ap-northeast-1:653AEC2-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxx/dataset/profileSet
在我的IAM角色中,我设置为:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "default"
},
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "authenticated"
}
}
}
]
}
以及政策:
{
“版本”:“2012-10-17”,
“声明”:[
{
“动作”:“cognito同步:”,
“效果”:“允许”,
“资源”:”
}
]
}
我遵循链接中的参考:
有人能帮我吗?问题已经解决了。我在替换我的IAM角色参数时出错。一切都是对的,只是我的剧本错了 多谢各位