What is a custom authentication token in Firebase?
A custom authentication token is a secure token created by your server to sign in users with Firebase Authentication when you want to manage your own user identities.
Click to reveal answer
beginner
Why would you use custom authentication tokens instead of Firebase's built-in sign-in methods?
You use custom tokens when you have your own user system or want to integrate Firebase Authentication with existing authentication methods outside Firebase.
Click to reveal answer
intermediate
Which Firebase Admin SDK method is used to create a custom authentication token?
The method is createCustomToken(uid, additionalClaims) where uid is the user ID and additionalClaims are optional extra data.
Click to reveal answer
beginner
What information must you include when creating a custom authentication token?
You must include a unique user ID (uid) and can optionally add extra claims like roles or permissions.
Click to reveal answer
beginner
How does a client use a custom authentication token to sign in?
The client receives the token from your server and calls signInWithCustomToken(token) to authenticate with Firebase.
Click to reveal answer
What is the main purpose of Firebase custom authentication tokens?
ATo replace Firebase Realtime Database
BTo create Firebase projects
CTo store user data securely
DTo sign in users with your own authentication system integrated with Firebase
✗ Incorrect
Custom tokens let you sign in users using your own authentication system with Firebase Authentication.
Which Firebase SDK is used to create custom authentication tokens?
AFirebase Storage SDK
BFirebase Admin SDK
CFirebase Client SDK
DFirebase Hosting SDK
✗ Incorrect
The Firebase Admin SDK runs on your server and creates custom tokens.
What is required to create a custom token?
AUser's email only
BUser's password
CA unique user ID (uid)
DFirebase API key
✗ Incorrect
A unique user ID (uid) identifies the user in the token.
How does the client authenticate with Firebase using a custom token?
ABy calling signInWithCustomToken(token)
BBy calling signInWithEmailAndPassword
CBy calling createUserWithEmailAndPassword
DBy calling signOut
✗ Incorrect
The client uses signInWithCustomToken(token) to authenticate with the custom token.
Can you add extra information like user roles in a custom token?
AYes, as additional claims
BNo, tokens only contain user ID
CYes, but only in the client SDK
DNo, Firebase does not support extra data
✗ Incorrect
You can add extra claims like roles or permissions when creating the token.
Explain how custom authentication tokens work in Firebase and why you might use them.
Think about how your server and client communicate to authenticate users.
You got /4 concepts.
Describe the steps to create and use a custom authentication token in Firebase.
Focus on server token creation and client sign-in.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of Firebase custom authentication tokens?
easy
A. To store user data in Firebase Realtime Database
B. To sign in users from your own system to Firebase
C. To send notifications to users
D. To create Firebase projects automatically
Solution
Step 1: Understand the role of custom tokens
Custom tokens are used to authenticate users from an external system with Firebase.
Step 2: Identify the correct purpose
They allow users to sign in securely using tokens generated on your server.
Final Answer:
To sign in users from your own system to Firebase -> Option B
Quick Check:
Custom tokens = sign in users [OK]
Hint: Custom tokens = external user sign-in method [OK]
Common Mistakes:
Confusing tokens with data storage
Thinking tokens send notifications
Assuming tokens create projects
2. Which Firebase Admin SDK method is used to create a custom authentication token?
easy
A. admin.auth().createCustomToken(uid)
B. admin.database().createToken(uid)
C. firebase.auth().signInWithCustomToken(uid)
D. admin.storage().generateToken(uid)
Solution
Step 1: Identify the correct Admin SDK service
Custom tokens are created using the Authentication service, not database or storage.
Step 2: Match the correct method
The method to create a custom token is createCustomToken(uid) under admin.auth().
B. Incorrect method name, should be generateCustomToken
C. createCustomToken does not return a Promise
D. UID must be a string, not a number
Solution
Step 1: Check initialization of Firebase Admin SDK
The admin SDK must be initialized with admin.initializeApp() before use.
Step 2: Verify other parts
The UID '12345' is a valid string, createCustomToken returns a Promise, and method name is correct.
Final Answer:
Missing admin.initializeApp() call -> Option A
Quick Check:
Initialize admin SDK before calling methods [OK]
Hint: Always call admin.initializeApp() before using admin SDK [OK]
Common Mistakes:
Passing number instead of string UID
Assuming createCustomToken is synchronous
Using wrong method name
5. You want to add extra user info like role: 'admin' in a custom token. Which code snippet correctly adds this claim?
hard
A. admin.auth().setCustomUserClaims(uid, { role: 'admin' })
B. admin.auth().createCustomToken(uid).setClaims({ role: 'admin' })
C. admin.auth().createCustomToken(uid, { role: 'admin' })
D. admin.auth().createCustomToken(uid, { claims: { role: 'admin' } })
Solution
Step 1: Understand how to add extra claims in custom tokens
The createCustomToken method accepts a second argument with additional claims as a plain object.
Step 2: Evaluate each option
admin.auth().createCustomToken(uid, { role: 'admin' }) correctly passes extra claims as second argument. admin.auth().createCustomToken(uid).setClaims({ role: 'admin' }) is invalid chaining. admin.auth().setCustomUserClaims(uid, { role: 'admin' }) sets claims on user but not in token creation. admin.auth().createCustomToken(uid, { claims: { role: 'admin' } }) nests claims incorrectly.
Final Answer:
admin.auth().createCustomToken(uid, { role: 'admin' }) -> Option C
Quick Check:
Extra claims go as second argument in createCustomToken [OK]
Hint: Pass extra claims as second argument to createCustomToken [OK]
Common Mistakes:
Trying to chain setClaims on token creation
Using setCustomUserClaims instead of token claims
Nesting claims inside another object
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.