android - 如何从 amazon cognito 提供的凭证访问 S3 存储桶?
问题描述
我正在使用 amazon s3 存储桶上传我的图片。我收到了来自 google 的警告邮件,说我的 AWS 凭证已暴露。所以现在我正在替换代码并使用 amazon cognito。
我无法访问存储桶。该错误表示访问被拒绝。
这是我的代码:
credentialsProvider = new CognitoCachingCredentialsProvider(
context, // get the context for the current activity
"xxxxxxx", // your AWS Account id
"ap-southeast-1:3d4e113d-4cd3-47ac-b5ef-xxxxxxxxxx", // your identity pool id
"arn:aws:iam::xxxxxxxxx:role/Cognito_trackusersUnauth_Role",// an authenticated role ARN
"arn:aws:iam::xxxxxxxxx:role/Cognito_trackusersAuth_Role", // an unauthenticated role ARN
Regions.AP_SOUTHEAST_1 //Region
);
s3 = new AmazonS3Client(credentialsProvider);
s3.setEndpoint("s3-ap-southeast-1.amazonaws.com");
这是它说访问被拒绝的地方:
List<Bucket> buckets = s3.listBuckets();
解决方案
推荐阅读
- android - Android View Binding问题,公共类名和文件名不同
- python - 在 Python 中使用用户输入作为变量
- google-sheets - 如何解决“读取请求限制错误”?
- python - 如何将正则表达式中的任何内容匹配到一个字符而不包括它?
- javascript - 如何在外部文件中使用 Vue 指令并导入组件?
- docker - 安装路径无效:“db”安装路径必须是绝对的
- c - c代码:结构及其字段的语法错误
- algorithm - 如何按小时对过去 24 小时的时间戳进行分组?
- stm32 - stm32 keil无法在中断中分配数组
- python - 用于自适应测试的计算机自适应测试模拟 (Catsim) 库