AWS Cognito 无效登录令牌错误,我的令牌来自开发人员身份验证

AWS Cognito Invalid login token error with my token from Developer authentication

我想直接从 angular js 上的浏览​​器将对象放入 AWS S3。
为此,我使用 cognito 开发人员身份验证。 我从我的 rails 服务器获得了 Cognito 身份 ID 和令牌。

使用该令牌(我认为它是有效的),我的放置操作被 AWS S3 拒绝:无效的登录令牌。
不知道为什么..

这是我的代码。

AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  AccountId: '0000',
  IdentityPoolId: 'us-east-1:0000-0000-0000',
  RoleArn: 'arn:aws:iam::0000:role/myRoleName',
  Logins: {
    'cognito-identity.amazonaws.com': 'token from cognito.get_open_id_token_for_developer_identity'
  }
});
var bucket = new AWS.S3({ params: { Region: 'ap-northeast-1', Bucket: 'my bucket name' }});

(0000个零件只是样品)
我想知道 cognito.get_open_id_token_for_developer_identity.
'identity_id' 没有 space Config regioin 和 s3 区域不同 因为我使用的是 tokyo S3 但 n.virginia Cognito。

++ 我在我的角色 (myRoleName) 中添加了对托管策略的 s3 完全访问权限,并在下面的设置中添加了内联策略。 (我还向内联策略添加了 'resource * version of below setting')

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "0000",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::myBucketName"
            ]
        }
    ]
}

您似乎正在尝试使用 "Basic authflow"。这是我们关于身份验证流程的文档的 link:
http://docs.aws.amazon.com/cognito/devguide/identity/concepts/authentication-flow/#developer-authenticated-identities-authflow

这没有使用您在登录映射中提供的令牌。

我推荐使用"Enhanced authflow"。为此:
(1) 确保您的身份池配置了您希望用户使用的角色:http://docs.aws.amazon.com/cognito/devguide/identity/concepts/iam-roles/
(2) 删除身份构造函数的 AccountId 和 RoleArn 参数。