【问题标题】:AWS cognito sync manager error synchronize to cloudAWS cognito 同步管理器错误同步到云
【发布时间】:2017-07-02 05:21:38
【问题描述】:

我有 javascript 客户端来执行 aws cognito 身份验证登录与提供商(Facebook、谷歌、Twitter 等)。我可以看到已成功从以下位置获取凭据:

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::xxxxxxxxxxxx:assumed-role/roleName/web-identity 无权执行:cognito-sync:ListRecords on resource: arn:aws:cognito-sync:ap-northeast-1:xxxxxxxxxxxx:identitypool/ap-northeast-1:c8250ce6-xxxx-xxxx-xxxx-xxxxxxxxxxxx/identity/ap-northeast-1:653aeca2-xxxx-xxxx-xxxx- xxxxxxxxxxxx/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”, “陈述”: [ { “行动”:“认知同步:”, “效果”:“允许”, “资源”:“” } ] }

我按照链接中的参考:

Amazon Cognito Sync Manager for JavaScript

有人可以帮帮我吗?

【问题讨论】:

    标签: synchronization amazon-cognito


    【解决方案1】:

    已经解决了。替换我的 IAM 角色参数时我错了。一切都是正确的,只有我的脚本错误。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 2017-01-26
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 2020-11-18
      • 1970-01-01
      相关资源
      最近更新 更多