Hasura Backend Plus is the authentication and storage technology that is very compatible with Hasura and very easy to use. It has the feature to implement social media authentication. In this blog, I will try to explain only google authentication, but the rest of social media authentication is kind of the same.
Step 1: Create a project in the google developer console
Go to the Google developer console and log in with your Google account. Click on the create project
button. Give your project name and click on the Save
button. Create a new project and go to the Credentials
sector. Then go to the Create credentials
menu and click on the OAuth client ID
option. You will get an OAuth consent screen
button, then click on it. Select your user type and click on the create
button. Put in your app information and click on the save and continue
button. Now you will go to the scope
section. Change the scope section as your app's requirement or leave it as it is. Then you go to the TestUsers
section, add one or more email addresses that you want to use for testing. Then go to the Credentials
sector again and click on the OAuth client ID
. Put your application type and name. Now you get the Authorized JavaScript origins and URLs
field. Put localhost:400 in this field and localhost:4000/auth/providers/google/callback in the Authorized redirect URIs
field. You will get the google client and secret key.
Step 2: Setup Google Authentication in the project
Now go to your project and paste google client id and secret key in the docker-composer.yml
file under the environment section.
GOOGLE_ENABLED:true
GOOGLE_CLIENT_ID:
GOOGLE_CLIENT_SECRET:
Don't forget to compose your docker-composer.yml
file. Now hit this API localhost:4000/auth/providers/google and you get the Sign in with Google option.
Enjoy your coding!