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

256
Vistas
How to use firebase.auth() in firebase-functions?

I'm trying to create a API and i want to use firebase.auth() for a signup endpoint in firebase functions with Express, but i cant find a way to get it working, this is what i have:

const functions = require("firebase-functions");
const admin = require('firebase-admin');
const app = require('express')();
admin.initializeApp();
const config = {
  //key
};

const db = admin.firestore();

const firebase = require('firebase/app');
firebase.initializeApp(config);
require('firebase/auth')



//singup route
app.post('/signup', (req, res) =>{
  const newUser = {
    email: req.body.email,
    password: req.body.password,
    confirmPass : req.body.password,
    nickName: req.body.nickName
  }
  //todo validate data

  firebase.auth().createUserWithEmailAndPassword(newUser.email, newUser.password)
    .then(data => {
      return res.status(200).json({message: `user ${data.user.uid} sign up siccesfully`});
    })
    .catch(err => {
      console.error(err);
      return res.status(500).json({error : err.code});
    })
});

Exist a way to acomplish this?

Notes : i tried using import, but firebase-functions doesnt work.

When i do a request in postman i get this error:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Error</title>
</head>

<body>
    <pre>TypeError: firebase.auth is not a function<br> &nbsp; &nbsp;at 

And nothing happend in firebase, then i want to be hable to create a user using my API, and return the token

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

move

require('firebase/auth')

above

firebase.initializeApp(config);

about 4 years ago · Juan Pablo Isaza Denunciar
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