我想直接从角度js上的浏览器将对象放入AWS S3。
为此,我使用cognito开发人员身份验证。 我从我的Rails服务器获得了认证身份标识和令牌。AWS Cognito来自开发人员身份验证令牌的令牌无效登录令牌错误
使用该令牌(我认为它是有效的),我的put操作在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部分只是样品)
不知有为 'identity_id'从cognito.get_open_id_token_for_developer_identity没有空间。
配置regioin和s3区域不同因为我使用东京S3但n.virginia Cognito。
++我在我的角色(myRoleName)中添加了s3对受管策略的完全访问权限,并将以下设置添加到内联策略中。 (我还在Inline策略中添加了'resource * version of below setting')
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "0000",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::myBucketName"
]
}
]
}
我试过增强authflow,但使用基本的authflow方法。现在我知道发生了什么,它的工作原理!谢谢! – cancue