0
0
Firebasecloud~10 mins

Linking multiple providers in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase with the correct configuration object.

Firebase
const app = initializeApp([1]);
Drag options to blanks, or click blank then click option'
Asettings
BconfigObject
CfirebaseConfig
DappConfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not hold the Firebase config object.
Passing an empty object or undefined.
2fill in blank
medium

Complete the code to link a Google provider to the current Firebase user.

Firebase
const provider = new GoogleAuthProvider();
const result = await linkWithPopup(auth.currentUser, [1]);
Drag options to blanks, or click blank then click option'
Aprovider
BtwitterProvider
CfacebookProvider
DgithubProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a different provider variable that is not initialized.
Passing the provider class instead of an instance.
3fill in blank
hard

Fix the error in the code to link a Facebook provider using a popup.

Firebase
const facebookProvider = new FacebookAuthProvider();
const user = auth.currentUser;
const linkedUser = await linkWithPopup([1], facebookProvider);
Drag options to blanks, or click blank then click option'
Auser
Bauth
Cauth.currentUser.uid
DfacebookProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the auth object instead of the user.
Passing the user ID string instead of the user object.
4fill in blank
hard

Fill both blanks to link Twitter and GitHub providers to the current user.

Firebase
const twitterProvider = new TwitterAuthProvider();
const githubProvider = new GithubAuthProvider();
await linkWithPopup(auth.currentUser, [1]);
await linkWithPopup(auth.currentUser, [2]);
Drag options to blanks, or click blank then click option'
AtwitterProvider
BgithubProvider
CfacebookProvider
DgoogleProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up provider variables.
Using providers not initialized in the code.
5fill in blank
hard

Fill all three blanks to handle linking Google, Facebook, and Twitter providers with error handling.

Firebase
try {
  await linkWithPopup(auth.currentUser, [1]);
  await linkWithPopup(auth.currentUser, [2]);
  await linkWithPopup(auth.currentUser, [3]);
} catch (error) {
  console.error('Error linking provider:', error);
}
Drag options to blanks, or click blank then click option'
AgoogleProvider
BfacebookProvider
CtwitterProvider
DgithubProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong provider names.
Not wrapping calls in try-catch for error handling.