Reputation: 41
My react application using aws amplify authentication and api gives me the following error in the console when logging in.
DataStore - User is unauthorized to query syncFriendships with auth mode API_KEY. No data could be returned.
What info do I need to provide, and to who, to figure out how to fix this error message? .
Upvotes: 1
Views: 2314
Reputation: 27
In aws-exports.js try changing "aws_appsync_authenticationType": "AWS_IAM", to whatever authentication type you are using like. For example, "aws_appsync_authenticationType": "API_KEY", https://docs.amplify.aws/lib/graphqlapi/authz/q/platform/js/
If this works you can make it permanent by running
amplify update api
then select graphql and update authorization modes.
Otherwise add additional authorization types in the AppSync schema: https://aws.amazon.com/blogs/mobile/using-multiple-authorization-types-with-aws-appsync-graphql-apis/
Upvotes: 1
Reputation: 284
Looks like error is during query from database. You are trying to access via graphQL via API_KEY
which is expired. You need to generate new api_key and add it in aws-exports.js
file. Follow this -
GraphQL
from set up panel on Amplify studio.Deployed graphql resources
.API Details
look for the api key. If it show empty then you need to generate new one.Default authorization mode
box.aws_appsync_apiKey
in aws-exports.js
file.Upvotes: 2
Reputation: 251
The user (you in your web browser) is not allowed to access the DataStore. You can either grant permissions for guest users or your user has to be signed in.
You can change the Authorization settings in Amplify Studio.
Upvotes: 0