DEV Community

Cover image for Node JS Google Authentication under 50 lines of code.
SushantDhiman2004
SushantDhiman2004

Posted on • Updated on • Originally published at crunchythings.xyz

Node JS Google Authentication under 50 lines of code.

Hello and welcome computer geeks. In this post we are going to to learn how to add google authentication in node JS application. We will be going to use Passport JS. So letโ€™s get started.

Requirements

There are two things required to add Google authentication in node JS project. The first thing is OAuth 2.0 client ID and client secret. The second thing is Passport JS npm package. So lets first generate OAuth 2.0 client ID and client secret.

How to generate Client ID & Client Secret

In order to generate them you have to go to this link and follow the below steps.

  1. Click on Create Credentials -> OAuth Client ID.
  2. Select Application type as Web Application.
  3. In redirection URL add http://localhost:3000/auth/google/callback
  4. Click on Create Button and itโ€™s done.

Read Complete Tutorial and Download Codes from here

Top comments (0)