Authentication of DocFinder using Auth APIs

3.3) Hasura Auth API + Postman collection

Hello guys, this is my eighth blog post for the Internship at Hasura! After getting through with Data Modelling of my web application DocFinder, and configuring Data API.

In this blog, I am going to describe about how to create authorization to the table using postman.

Hasura Auth APIs is a collection of APIs for creating, managing and authenticating user identities into your webapp. In addition to creating. logging in and logging out, the Auth APIs also provide authentication tokens, thus making it easier to maintain sessions.

Another feature is that you have different roles of users — admin, user, anonymous. And you can assign permissions based on the role that a user has. In addition to the default roles. you can also create roles specific to your app requirement. The default role assigned to any user is the role ‘user’.

Head over to your Hasura Console and under Auth and User Management section you can find the external endpoint for using Hasura Auth services.

Now here are some of the sample auth API queries made using Postman, referring from Auth documentation and users, roles and sessions (Register, Login, and Logout are POST requests where as User Info is a GET request):

Signup request:

This is a POST request made to URL endpoint : http://auth.c100.hasura.me/signup

After making signup request the new user is now given a session token,and he/she is considered as registered and now he/she can sign in as a user.

We can see the updation in the console:

Login request:

This is also a POST request made to the URL endpoint : http://auth.c100.hasura.me/login

After login one can access the data from the table,and make data API requests.every time when a user logs he/she is given with a session token to access the API.if he /she try’s to access with the invalid token then access is denied.

We can see the updation in the console:

Log Out Request :

This is a POST request (but formerly was a GET request in older version of hasura local development) which is made to URL endpoint :

http://auth.c100.hasura.me/user/logout

Logout

Here are some resources which I used for the Auth API -

Here’s the documentation link

Hasura 0.6 documentation
https://hasura.io/_docs/platform/0.6/getting-started/2-user-model.html

Video Illustration about Auth APIs :

Coming Up!

In the next blog, I’ll talk about (UI + Backend integration) for App Screen 1 of my web application Doc Finder.