AWS Amplify AppSync IAM 401 [英] AWS Amplify AppSync IAM 401
问题描述
我收到 GraphQLError: Request failed with status code 401
我按照以下自动配置说明进行操作:
I followed the automatic configuration instructions from:
https://aws.github.io/aws-amplify/media/api_guide#automated-configuration-with-cli
我尝试寻找,但缺乏 IAM 资源.看起来一切都应该自动设置,并在我输入 IAM 访问密钥和机密后使用 Amplify CLI 完成.
I tried looking, but there are a lack of resources for IAM. It looks like everything should be setup automatically, and done with the Amplify CLI after I put in the IAM access key and secret.
是否需要进一步设置?这是我的代码:
Is further setup required? Here is my code:
import Amplify, { API, graphqlOperation, Hub } from "aws-amplify";
import aws_config from "../../aws-exports";
Amplify.configure(aws_config);
const ListKeywords = `query ListKeywords {
listKeyword {
keyword {
id
name
}
}
}`;
const loop = async () => {
const allKeywords = await API.graphql(graphqlOperation(ListKeywords));
}
是否也可能是因为我的 GraphQL 解析器还没有为 ListKeywords 设置?
Could it also be because my GraphQL resolvers are not setup yet for ListKeywords?
推荐答案
我刚刚更改了 ~/.aws/credentials
,现在可以使用了.
I just changed ~/.aws/credentials
and now it's working.
看起来即使您通过 Amplify 的命令行工具或 ~/.awsmobile/aws-config.js
进行了项目特定配置,它仍然依赖于 ~/.aws
Looks like even if you have project specific configuration via Amplify's command line tools or ~/.awsmobile/aws-config.js
, it still relies on ~/.aws
这篇关于AWS Amplify AppSync IAM 401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!