0
0
Firebasecloud~10 mins

Facebook sign-in 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 the Facebook auth provider.

Firebase
const provider = new firebase.auth.[1]();
Drag options to blanks, or click blank then click option'
AFacebookAuthProvider
BGoogleAuthProvider
CTwitterAuthProvider
DGithubAuthProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Using GoogleAuthProvider instead of FacebookAuthProvider
Misspelling the provider name
Forgetting to create a new instance with parentheses
2fill in blank
medium

Complete the code to trigger the Facebook sign-in popup.

Firebase
firebase.auth().signInWith[1](provider).then(result => {
  // handle result
});
Drag options to blanks, or click blank then click option'
ARedirect
BPopup
CCredential
DToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using signInWithRedirect instead of signInWithPopup
Misspelling the method name
Not passing the provider as argument
3fill in blank
hard

Fix the error in the code to get the Facebook access token from the result.

Firebase
const credential = result.credential;
const token = credential.[1];
Drag options to blanks, or click blank then click option'
AauthToken
BtokenId
CfacebookToken
DaccessToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using tokenId or authToken which do not exist
Trying to access token directly on result
Misspelling accessToken
4fill in blank
hard

Fill both blanks to handle sign-in errors and get the error message.

Firebase
firebase.auth().signInWithPopup(provider).catch(error => {
  const errorCode = error.[1];
  const errorMessage = error.[2];
  console.error(errorCode, errorMessage);
});
Drag options to blanks, or click blank then click option'
Acode
Bmessage
Cmsg
DerrorMsg
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like msg or errorMsg
Trying to access error details outside the catch block
Not logging both code and message
5fill in blank
hard

Fill all three blanks to extract user info after Facebook sign-in.

Firebase
firebase.auth().signInWithPopup(provider).then(result => {
  const user = result.[1];
  const name = user.[2];
  const email = user.[3];
  console.log(`User: ${name}, Email: ${email}`);
});
Drag options to blanks, or click blank then click option'
Auser
BdisplayName
Cemail
Dprofile
Attempts:
3 left
💡 Hint
Common Mistakes
Using result.profile instead of result.user
Accessing name instead of displayName
Forgetting to get email from user object