Bird
Raised Fist0
Firebasecloud~20 mins

Linking multiple providers in Firebase - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Firebase Multi-Provider Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What happens when you link multiple providers to a Firebase user?

In Firebase Authentication, what is the main effect of linking multiple providers (like Google and Facebook) to a single user account?

AEach provider creates a separate user account with isolated data.
BThe user can sign in using any linked provider and access the same account data.
CLinking providers merges user data from all providers automatically without user consent.
DLinking providers disables sign-in from the original provider.
Attempts:
2 left
💡 Hint

Think about how linking providers affects user sign-in options.

❓ Configuration
intermediate
2:00remaining
Which Firebase method links a new provider to an existing user?

Given an authenticated Firebase user, which method correctly links a new OAuth provider credential to their account?

Firebase
const credential = firebase.auth.GoogleAuthProvider.credential(idToken);
// User is already signed in
// Which method links the credential to the user?
Afirebase.auth().currentUser.linkWithCredential(credential)
Bfirebase.auth().linkUserWithCredential(credential)
Cfirebase.auth().currentUser.signInWithCredential(credential)
Dfirebase.auth().linkCredentialToUser(credential)
Attempts:
2 left
💡 Hint

Check the Firebase user object methods for linking credentials.

❓ Architecture
advanced
2:30remaining
How to design user data storage for multiple linked providers?

You want to store user profile data in Firestore for users who sign in with multiple linked providers. What is the best practice for structuring this data?

AStore one user document per Firebase UID with a nested field listing all linked providers.
BCreate separate user documents for each provider linked to the same email.
CStore user data only under the first provider used to sign up.
DDuplicate user data in multiple collections, one per provider.
Attempts:
2 left
💡 Hint

Consider how Firebase UID relates to user identity across providers.

❓ security
advanced
2:30remaining
What security risk arises if you do not verify provider emails before linking?

When linking multiple providers to a Firebase user, what risk occurs if you do not verify that the email addresses from providers match and are verified?

AUsers will be unable to sign in with any provider after linking.
BFirebase automatically prevents any security risks without verification.
CAn attacker could link their provider account to another user's Firebase account and gain access.
DThe linked providers will lose their authentication tokens.
Attempts:
2 left
💡 Hint

Think about what happens if two accounts share the same email but are not verified.

❓ service_behavior
expert
3:00remaining
What is the Firebase user state after unlinking a provider?

After unlinking a provider from a Firebase user who has multiple linked providers, what is the state of the user account?

AThe user loses access to all linked providers until re-linked.
BThe user is signed out immediately and must sign in again.
CThe user account is deleted if any provider is unlinked.
DThe user remains signed in and can sign in with remaining linked providers.
Attempts:
2 left
💡 Hint

Consider what unlinking a provider means for the user's authentication options.

Practice

(1/5)
1. What is the main purpose of linking multiple providers in Firebase Authentication?
easy
A. Encrypt user passwords for security
B. Allow users to sign in using different login methods for the same account
C. Automatically delete old user accounts
D. Create multiple accounts for one user

Solution

  1. Step 1: Understand user account linking

    Linking multiple providers means connecting different login methods (like Google, Facebook) to one user account.
  2. Step 2: Identify the purpose

    This allows users to sign in with any linked provider but access the same account.
  3. Final Answer:

    Allow users to sign in using different login methods for the same account -> Option B
  4. Quick Check:

    Linking providers = multiple logins one account [OK]
Hint: Linking means one account, many login ways [OK]
Common Mistakes:
  • Thinking linking creates multiple accounts
  • Confusing linking with password encryption
  • Assuming linking deletes old accounts
2. Which Firebase method is used to link a new provider to an existing signed-in user using a popup?
easy
A. createUserWithEmailAndPassword
B. signInWithPopup
C. linkWithPopup
D. signOut

Solution

  1. Step 1: Recall Firebase linking methods

    To link a new provider, Firebase offers methods like linkWithPopup and linkWithCredential.
  2. Step 2: Identify the popup linking method

    linkWithPopup is specifically for linking using a popup window.
  3. Final Answer:

    linkWithPopup -> Option C
  4. Quick Check:

    Popup linking method = linkWithPopup [OK]
Hint: Popup linking always uses linkWithPopup [OK]
Common Mistakes:
  • Using signInWithPopup instead of linkWithPopup
  • Confusing createUserWithEmailAndPassword with linking
  • Trying to link without a signed-in user
3. Consider this code snippet:
const user = firebase.auth().currentUser;
const credential = firebase.auth.GoogleAuthProvider.credential(idToken);

user.linkWithCredential(credential)
  .then(() => console.log('Linked!'))
  .catch(error => console.log(error.message));

What will happen if user is null?
medium
A. An error will occur because no user is signed in
B. The user will be linked successfully
C. The code will silently do nothing
D. A new user account will be created automatically

Solution

  1. Step 1: Check currentUser value

    If user is null, it means no user is signed in currently.
  2. Step 2: Understand linkWithCredential behavior

    linkWithCredential requires a signed-in user to link a new provider. Without a user, it throws an error.
  3. Final Answer:

    An error will occur because no user is signed in -> Option A
  4. Quick Check:

    Null user + linkWithCredential = error [OK]
Hint: Linking needs signed-in user; null means error [OK]
Common Mistakes:
  • Assuming linking works without a signed-in user
  • Expecting silent failure instead of error
  • Thinking a new user is created automatically
4. You try to link a Facebook provider to a user but get an error: "auth/credential-already-in-use". What is the likely cause?
medium
A. The user is not signed in
B. The Firebase project is not configured for Facebook login
C. The Facebook SDK is not initialized
D. The Facebook account is already linked to another Firebase user

Solution

  1. Step 1: Understand the error message

    "auth/credential-already-in-use" means the credential (Facebook account) is linked to a different Firebase user.
  2. Step 2: Identify cause of error

    Trying to link a provider already linked to another user causes this error.
  3. Final Answer:

    The Facebook account is already linked to another Firebase user -> Option D
  4. Quick Check:

    Credential in use = linked to another user [OK]
Hint: Credential already linked means another user owns it [OK]
Common Mistakes:
  • Assuming user not signed in causes this error
  • Blaming SDK initialization instead of credential conflict
  • Ignoring Firebase project configuration issues
5. You want to let users link Google and Facebook providers to one account. Which sequence correctly links both providers safely?
hard
A. Sign in user, link Google with linkWithPopup, then link Facebook with linkWithCredential
B. Link Google with linkWithPopup before sign-in, then sign in user, then link Facebook
C. Sign in user, link Facebook with linkWithPopup, then sign out and link Google
D. Create user with Facebook, then create user with Google, then merge accounts manually

Solution

  1. Step 1: Ensure user is signed in before linking

    Linking requires a signed-in user, so sign in first.
  2. Step 2: Link providers one by one

    Use linkWithPopup or linkWithCredential to link Google and Facebook safely after sign-in.
  3. Step 3: Avoid signing out before linking all providers

    Signing out breaks the user session and prevents linking multiple providers to one account.
  4. Final Answer:

    Sign in user, link Google with linkWithPopup, then link Facebook with linkWithCredential -> Option A
  5. Quick Check:

    Sign in first, then link providers [OK]
Hint: Always sign in before linking multiple providers [OK]
Common Mistakes:
  • Trying to link providers before signing in
  • Signing out between linking providers
  • Creating separate users instead of linking
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard