gpt4 book ai didi

amazon-web-services - AWS Amplify with React Native : Credentials should be scoped to a valid region, 而不是 us-east-1

转载 作者:行者123 更新时间:2023-12-02 17:04:17 24 4
gpt4 key购买 nike

我正在尝试使用适用于 React Native 的 AWS Amplify SDK 和 API Gateway 中的 IAM 授权方发出简单的获取请求。我总是收到以下错误消息:

Credential should be scoped to a valid region, not 'us-east-1'.

我做错了什么?这是我的代码(还没有做任何事情):

function getImageIdForUpload() {
let apiName = 'MyAPIGatewayAPI';
let path = '/upload-image/get-new-id';
let myInit = {
// replace this with attributes you need
};

API.get(apiName, path, myInit).then(response => {
console.log(response)
}).catch(error => {
console.error(error.response)
});
}

我的配置:

Auth: {
// REQUIRED - Amazon Cognito Identity Pool ID
identityPoolId: 'eu-central-1:xxxx',
// REQUIRED - Amazon Cognito Region
region: 'eu-central-1',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'eu-central-1_xxxx',
// OPTIONAL - Amazon Cognito Web Client ID
userPoolWebClientId: 'xxxx',
},

任何帮助将不胜感激:)

最佳答案

我自己找到了解决方案:您必须在 API 配置中设置区域。

例子:

API: {
endpoints: [
{
name: "MyAPIGatewayAPI",
endpoint: "https://xxx.execute-api.eu-central-1.amazonaws.com/dev",
region: "eu-central-1"
}
]
},

如果 API 设置为“边缘优化”,这可能不是问题。

关于amazon-web-services - AWS Amplify with React Native : Credentials should be scoped to a valid region, 而不是 us-east-1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52473070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com