Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda