![](/img/trans.png)
[英]Authenticating user in AWS Cognito User/Identity Pool with Google as identity provider
[英]Is there a way to use AWS Amplify library (JavaScript) to access s3 bucket without cognito user poool and identity pool?
我正在嘗試使用 amplify 庫(JavaScript 使用 STS 生成的臨時訪問密鑰和秘密訪問密鑰訪問 s3 存儲桶。但似乎我需要一個認知用戶池和身份池。
import Amplify, { Storage } from 'aws-amplify';
Amplify.configure({
Storage: {
region: 'ap-south-1',
endpoint: "http://localhost:4572",
bucket: 'mybucket',
}
})
Storage.list('photos/').then(res => console.log(res)).catch(err => console.log(err))
有沒有辦法在不使用 AWS SDK 的情況下實現這一目標?
[WARN] 56:56.803 AWSS3Provider - ensure credentials error No Cognito Identity pool provided for unauthenticated access
No credentials
您可以使用 AWS SDK for javascript,它在底層使用 AWS API。 在這種情況下,您需要將 s3 存儲桶公開/向所有人開放,或者使用 AWS IAM 憑證,這不是一種安全的方式。
通常不建議直接在 Amplify 中使用 IAM 憑證,因為滾動您自己的身份驗證/授權(決定是否授予 STS 憑證的過程)是危險的。
然而,這樣做有很多正當理由,所以這里是: 這個 GitHub 線程是關於這個問題的,並說你可以通過像這樣的代碼來做到這一點
AWS.config.update({
credentials: new AWS.Credentials({
accessKeyId: 'the key',
secretAccessKey: 'the other key'
})
});
在你的Amplify.configure()
之前
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.