What is the Firebase Admin SDK used for in Node.js?
It allows server-side Node.js applications to securely interact with Firebase services like authentication, database, and messaging.
Click to reveal answer
beginner
How do you initialize the Firebase Admin SDK in a Node.js app?
By importing the admin module and calling admin.initializeApp() with proper credentials.
Click to reveal answer
intermediate
Which Firebase service can you manage using the Admin SDK to verify user identity tokens?
Firebase Authentication service can be managed to verify ID tokens and manage users.
Click to reveal answer
intermediate
What is a common way to provide credentials to the Firebase Admin SDK in Node.js?
Using a service account JSON file downloaded from the Firebase console and passing it to admin.initializeApp().
Click to reveal answer
intermediate
Can the Firebase Admin SDK be used to send push notifications? If yes, how?
Yes, it can send push notifications using Firebase Cloud Messaging (FCM) by calling admin.messaging().send() with message details.
Click to reveal answer
What method initializes the Firebase Admin SDK in Node.js?
Aadmin.start()
Bfirebase.initialize()
Cfirebase.adminInit()
Dadmin.initializeApp()
✗ Incorrect
The correct method to initialize the Firebase Admin SDK is admin.initializeApp().
Which file type is commonly used to provide credentials to the Admin SDK?
A.env file
BPlain text file
CService account JSON file
DYAML config file
✗ Incorrect
A service account JSON file downloaded from Firebase console is used for credentials.
Which Firebase service can the Admin SDK NOT manage?
AFirebase Hosting
BRealtime Database
CCloud Messaging
DAuthentication
✗ Incorrect
Firebase Hosting is managed via Firebase CLI, not the Admin SDK.
What does admin.auth().verifyIdToken() do?
ACreates a new user
BVerifies a user's ID token
CDeletes a user
DSends a notification
✗ Incorrect
It verifies the authenticity of a Firebase Authentication ID token.
Which method sends a push notification using the Admin SDK?
Aadmin.messaging().send()
Badmin.push().notify()
Cadmin.notify().send()
Dadmin.message().push()
✗ Incorrect
The method admin.messaging().send() is used to send push notifications.
Explain how to securely initialize the Firebase Admin SDK in a Node.js application.
Think about how to provide credentials and start the SDK.
You got /3 concepts.
Describe how the Firebase Admin SDK helps manage user authentication in Node.js.
Focus on user identity and token verification.
You got /3 concepts.
Practice
(1/5)
1. What is the primary purpose of the Firebase Admin SDK in Node.js?
easy
A. To build user interfaces for Firebase apps
B. To securely manage Firebase services from a server environment
C. To run Firebase apps directly in the browser
D. To replace Firebase client SDK on mobile devices
Solution
Step 1: Understand Firebase Admin SDK role
The Admin SDK is designed for server-side use to manage Firebase services securely.
Step 2: Differentiate from client SDKs
Client SDKs run on user devices for app interaction, while Admin SDK runs on servers for management tasks.
Final Answer:
To securely manage Firebase services from a server environment -> Option B
Quick Check:
Admin SDK = server management [OK]
Hint: Admin SDK is for backend server tasks, not frontend apps [OK]
Common Mistakes:
Confusing Admin SDK with client SDK
Thinking Admin SDK runs in browsers
Assuming Admin SDK builds UI
2. Which of the following is the correct way to initialize the Firebase Admin SDK in Node.js using a service account JSON file named serviceAccountKey.json?
easy
A. const admin = require('firebase-admin');
admin.initializeApp({credential: admin.credential.cert(require('./serviceAccountKey.json'))});
B. const admin = require('firebase-admin');
admin.initializeApp({serviceAccount: 'serviceAccountKey.json'});
C. const admin = require('firebase-admin');
admin.initializeApp({credential: admin.credential.applicationDefault()});
D. const admin = require('firebase-admin');
admin.initializeApp({credential: admin.credential.cert(serviceAccountKey.json)});
Solution
Step 1: Load service account JSON correctly
The service account JSON must be imported using require to pass the object, not a string path.
Step 2: Use admin.credential.cert with the JSON object
Pass the imported JSON object to admin.credential.cert for proper initialization.
Final Answer:
const admin = require('firebase-admin');
admin.initializeApp({credential: admin.credential.cert(require('./serviceAccountKey.json'))}); -> Option A
Quick Check:
Use require() to load JSON for cert [OK]
Hint: Use require() to load JSON, not a string path [OK]
Common Mistakes:
Passing file path string instead of JSON object
Using applicationDefault() when service account is needed
Incorrect property name like 'serviceAccount'
3. Given the following Node.js code using Firebase Admin SDK, what will be the output if the user with UID 'user123' exists?