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

224
Views
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 answers
Answer question

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 Report
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!