Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda