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

220
Vistas
A script to create Firebase user and add claims quickly?

I was wondering if anyone had a script on hand that can take a path to the admin JSON config file and create users with custom claims?

I've never written a script but guessing something like this

import FirebaseAdmin
import "./config.json"

//maybe gets the userID from the console?
createUser() {
...create user and attach the claims
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here is a Node.js script that will create two users and assign them a role claim. You can add as much users as you want, just copy/paste and adapt the const p1 block and add the p<X> promise to the Array.

You run it by calling node thenameofthescriptfile.js

#!/usr/bin/node
const admin = require('firebase-admin');

admin.initializeApp({
    credential: admin.credential.cert("xyz.json")
});

const p1 = admin.auth()
    .createUser({
        email: '...',
        password: '....',
        displayName: '....'
    })
    .then((userRecord) => {
        return admin.auth().setCustomUserClaims(userRecord.uid, { role: "..." })
    })
    .catch((error) => {
        console.log('Error creating new user:', error);
    });

const p2 = admin.auth()
    .createUser({
        email: '...',
        password: '....',
        displayName: '....'
    })
    .then((userRecord) => {
        return admin.auth().setCustomUserClaims(userRecord.uid, { role: "..." })
    })
    .catch((error) => {
        console.log('Error creating new user:', error);
    });

Promise.all([p1, p2]);
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