Search code examples
firebasefirebase-authenticationfacebook-authentication

How do you access Facebook scope data with Firebase Auth


I'm trying to access data requested from Facebook. Here is my code:

  var auth_provider_facebook = new firebase.auth.FacebookAuthProvider();

/// BEGIN: configure the facebook authorization provider.
  auth_provider_facebook.addScope('user_birthday');
  auth_provider_facebook.addScope('user_about_me');
  auth_provider_facebook.addScope('user_work_history');
  auth_provider_facebook.addScope('user_education_history');

 // auth_provider_facebook.addScope('user_birthday,user_about_me,user_work_history,user_education_history');

/// END: configure the facebook authorization provider.

I've tried one-lining it and multi-lining it, but I am still having trouble getting the data. The documentation found here has absolutely no information on retrieving data from the scope. The documentation provided here mentions a facebook variable as part of the result, but it's always undefined. There's more documentation here that brings up a thirdPartyUserData property which is also always undefined.

How do I go about obtaining this data?


Solution

  • When you authenticate, onAuthStateChange will give you a token. This is mine with multiple account linked.

    Can you find it? Are you using Firebase v3?

    enter image description here