Public Access to data model for all users

0

Hi I'm trying to allow all users to access this group data model. I'm not sure if the configuration is correct. I didn't place any @auth rules as I would like the data model to be publicly accessible. I've tried doing something like @auth (rules : [ { allow : public ]) and it gave me an error : InvalidDirectiveError: @auth directive with 'apiKey' provider found, but the project has no API Key authentication provider configured. I'm using Amazon Cognito User Pool

I'm using cognito username for authentication login

This is my implementation of querying data, schema.graphql and error

Enter image description here

  • I've tried changing the schema.graphl to

    type Group @model @auth(rules: [ { allow: public, provider: apiKey } ]){ id: ID! members: [String!]! location: String time: String specialRequest: String }

    and amplify update API to add a API authentication

    but it still throws the same error

1 個回答
1
已接受的答案

In order for your data to be accessible to all signed in user, do this

Signed-in user data access To restrict a record's access to every signed-in user, use the private authorization strategy.

If you want to restrict a record's access to a specific user, see Per-user / owner-based data access. private authorization applies the authorization rule to every signed-in user access.

type Todo @model @auth(rules: [{ allow: private }]) { content: String }

https://docs.amplify.aws/cli/graphql/authorization-rules/#signed-in-user-data-access

已回答 1 年前
profile picture
專家
已審閱 1 年前
profile picture
專家
已審閱 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南