Creating a user, crediting roles to them, managing their details and functions is the prime thing required for any app. Thus authentication service is of paramount importance. This feature facilitates login and logout related functionalities.
In Hasura, auth service and APIs are an integral part of the project. These are inbuilt in every hasura project console and we need not work on it. Also it is easy to use.
Adding a User
There are two ways for us to add any user.
- We can head to the Users tab in our project console and add a user by filling in the required fields like shown below:
The second way is by using the external endpoint URLand in Postman write a JSON query and make a signup API request. Refer to the screenshot below:
A User will be created and an auth_token will be generated which will act as the session token. When the user logs out, the session token will be deleted and a new one will be generated the next time user logs in.
This new user will be added and could be checked in the project console as well:
The User info could also be checked in Postman using the API request method to fetch data:
This sums up auth API and its use in Hasura project.