Question:
I’m getting 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
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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)); } |
Could it also be because my GraphQL resolvers are not setup yet for ListKeywords?
Answer:
I just changed ~/.aws/credentials
and now it’s working.
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