DEV Community

Oren Zbeda
Oren Zbeda

Posted on

Social login made really easy

There are many social login libraries out there.
They all require registration and are domain dependent.

They are also hard to understand at first look.

This does not have to be.

We tried a different approach to social login

We do all the heavy lifting and return a signed JWT.
We also supply the npm module to verify this jwt and put the login info into the request and even the session.

So how to use it:

just add these lines:

const azauth=require('azauth');
app.use(azauth.auth);

Belive it or not you are done !!!!

Create your login button like this:


<a href="http://auth.azjs.io/googleAuth/authTo/{callback url}" GOOGLE LOGIN </a>

Where "{callback url}" is your website login rout (remember to encodeuricomponent this valeu)

Now on your server you will get the user profile at the {callback url} on the request.azAuth.data

For example:

app.get('/afterLoginCallback',  function(req,res){
    console.log(req.azAuth.data) //this holdes the user profile  
   res.send(`Hi <b> ${req.azAuth.data.emails[0].value} </b> <br>this all the profile info <br> ${JSON.stringify(req.azAuth.data)}` )

})

Enter fullscreen mode Exit fullscreen mode

That is all. You are done.
Be happy to hear what you think about it.

This is a short explainer video : https://github.com/orenz/azauth
This is the git: https://github.com/orenz/azauth

Thanks

Top comments (0)