Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Login via Google in React application using Passportjs

I`m working on project that contains 2 apps: web-site and chrome extension. Web-site technologies stack: Nodejs, Mongoose, React.

For now, I`m trying to realize authentication via Google+, using Passportjs. Why Passportjs ? Because I want to use many authentication flows.

First of all, I make a simple auth flow with login and password:

  • on register, I add user to db.
  • on logIn, I check user credentials from db. If all right, I send token to client and save it to localStorage. In future, I want to use token to authenticate user.

Why token? Because in chrome extension I need authentication too.

Look at my code: (files in this gist)

LogIn realization: local-login.js file

SignUp realization: local-signup.js file

I have a login page, which makes AJAX request to server with login and password: LoginPage.jsx file

When I tried to make authorization via Google I experienced some problems. My Google authorization code: google-login.js file

How I must return token to client? (for saving in localStorage) And, where I can get the right token? accessToken(parameter in passport callback) - is it that what I need?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!