0
0
Firebasecloud~30 mins

Firebase Admin SDK (Node.js) - Mini Project: Build & Apply

Choose your learning style9 modes available
Firebase Admin SDK (Node.js) Basic Setup and User Management
📖 Scenario: You are building a backend service that manages users in a Firebase project. You will set up the Firebase Admin SDK in Node.js, configure it with service account credentials, create a new user, and then update that user's display name.
🎯 Goal: Set up Firebase Admin SDK in Node.js, initialize it with service account credentials, create a user with email and password, and update the user's display name.
📋 What You'll Learn
Create a variable admin by requiring firebase-admin
Initialize Firebase Admin SDK with a service account object called serviceAccount
Create a new user with email user@example.com and password securePass123
Update the created user's display name to John Doe
💡 Why This Matters
🌍 Real World
Backend services often need to manage users securely. Firebase Admin SDK allows server-side user management like creating, updating, and deleting users.
💼 Career
Understanding Firebase Admin SDK is useful for backend developers working with Firebase projects, enabling secure user management and integration with other backend logic.
Progress0 / 4 steps
1
Setup Firebase Admin SDK import and service account
Create a constant called admin by requiring the firebase-admin module. Then create a constant called serviceAccount and assign it the object { projectId: 'my-firebase-project', clientEmail: 'firebase-admin@my-firebase-project.iam.gserviceaccount.com', privateKey: '-----BEGIN PRIVATE KEY-----\nABC123\n-----END PRIVATE KEY-----\n' }.
Firebase
Need a hint?

Use require('firebase-admin') to import the SDK. The serviceAccount is a plain object with keys projectId, clientEmail, and privateKey.

2
Initialize Firebase Admin SDK
Initialize Firebase Admin SDK by calling admin.initializeApp with an object that has a credential property set to admin.credential.cert(serviceAccount).
Firebase
Need a hint?

Use admin.initializeApp with credential: admin.credential.cert(serviceAccount) to initialize the SDK.

3
Create a new user with email and password
Use admin.auth().createUser with an object containing email: 'user@example.com' and password: 'securePass123'. Assign the returned promise to a constant called userRecordPromise.
Firebase
Need a hint?

Call admin.auth().createUser with the email and password inside an object. Assign the result to userRecordPromise.

4
Update the user's display name
Use userRecordPromise.then to get the userRecord. Inside the then callback, call admin.auth().updateUser with userRecord.uid and an object setting displayName to 'John Doe'.
Firebase
Need a hint?

Use userRecordPromise.then to get the user record, then call admin.auth().updateUser with the user's UID and the new display name.