Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access public api in hasura

Tags:

graphql

hasura

I'm running a docker container with admin secret. In the below image, you can see the roles under the permissions window. enter image description here

For category table, I set public role for SELECT option and there is no restriction for that role to access any query.

enter image description here

But my problem is I can't access the query using public role, hasura engine ask admin-secret. see the below image. How can I access this API without giving admin credentials? enter image description here

like image 486
Akash D Avatar asked Sep 06 '25 13:09

Akash D


1 Answers

Relevant docs: https://hasura.io/docs/1.0/graphql/manual/auth/authentication/unauthenticated-access.html#unauthenticated-public-access

If you are using webhook-based authentication, "for unauthenticated access, you can return a 200 status response with your defined unauthenticated role, e.g: { "x-hasura-role": "<anonymous-role>" }."

If you are using jwt-based authentication, "you can use the env variable HASURA_GRAPHQL_UNAUTHORIZED_ROLE or --unauthorized-role flag to set a role for unauthenticated (non-logged in) users."

The unauthenticated role can be called anything, in your case it would be "public"

like image 53
avimoondra Avatar answered Sep 08 '25 21:09

avimoondra