DEV Community

Cover image for Setting up Social Logins(Google + Microsoft) with Node.js and Passport.js

Setting up Social Logins(Google + Microsoft) with Node.js and Passport.js

Asim on October 07, 2020

Before diving into code, let's first briefly discuss what the heck is Oauth? What is Oauth: OAuth(or Open Authorization) is one of the ...
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
maciejwiatr profile image
Info Comment hidden by post author - thread only accessible via permalink
wiatr.dev

I'd be very thankfull 😅

Collapse
 
brianmcbride profile image
Brian McBride

The OAuth developer view is great.

I will say that if you want to go ultra simple, Google still offers Firebase Auth for pretty much free. It doesn't mean you need to use GCP for all your services either. And it although it isn't perfect, you can't beat it for the price anywhere.

Collapse
 
asim_ansari7 profile image
Asim

Thanks for the feedback.
I agree with that as I have used firebase social auth in some personal projects which is pretty easy to setup. Though I feel, with so many frameworks and libraries out there the level of abstraction has increased significantly and at times some of us get lost in setting things up from scratch and knowing how the thing actually works under the hood.
I just shared the minimal barebone of setting things up with Node, and even passport could have been avoided here to keep it more basic.

Collapse
 
orenz profile image
Oren Zbeda • Edited

Hi,

This is a lot of work.
I created this: github.com/orenz/azauth
It will allow social login in about 3 lines of code (really).

Also did a short video explainer.
youtu.be/5WehZTrgG8o

Hope you like.

Collapse
 
arifamujawar profile image
Arifa

Hello Asim,

I have used the same library to provide Microsoft verification. I am able to fetch the profile of a user, but my application checks the passport verification again and the application crashes. Did you face the same problem with Microsoft verification?

Collapse
 
asim_ansari7 profile image
Asim

Hey Arifa,
Is the redirection URL the same in both the application and Microsoft portal?
If this true, check for these keys in the manifest file (found under AppRegistration, Manifest tab)
"accessTokenAcceptedVersion" : 2
"signInAudience" : "AzureADandPersonalMicrosoftAccount"
I did face an issue because of this and setting this to the above values fixed it.
Relevant Resources:
docs.microsoft.com/en-gb/azure/act...
docs.microsoft.com/en-gb/azure/act...

Collapse
 
arifamujawar profile image
Arifa

Thanks, Asim. I got it working. I simply added { session: false } in the middleware file.

Collapse
 
nicolasomar profile image
Nicolás Omar González Passerino

Thanks man, I think this is a sweet feature to add in almost any app.
You gave me a great starting point from here.

Collapse
 
long_yoda profile image
Vo Hoang Long

Awesome content. Thank you

Collapse
 
clintonmwachia profile image
ClintonMoshe

Awesome content. Thanks man

Collapse
 
nehanegi220682 profile image
nehanegi220682

Thank you so much from Yatin and Neha :-P

Collapse
 
bhargu27 profile image
Bhargav kanodiya

is app registration on microsoft are free or not

Some comments have been hidden by the post's author - find out more