How to get Facebook public profile data using angularfire auth and firebase


#1

I’m trying to get data from users’ Facebook profiles who login/signup in my app with Facebook like their birthday, images, gender etc. Right now I’m just adding arbitrary values to my database but I want to get their gender, profile picture url, and birthday if possible. For the life of me I can’t figure out how to do it. Here’s what I have so far:

loginWithFacebook() {
return Observable.create(observer => {
  if (this.platform.is('cordova')) {
    Facebook.login(['public_profile', 'email']).then(facebookData => {
      console.log(facebookData);
      let provider = firebase.auth.FacebookAuthProvider.credential(facebookData.authResponse.accessToken);
      firebase.auth().signInWithCredential(provider).then(firebaseData => {
        this.af.database.list('users').update(firebaseData.uid, {
          name: firebaseData.displayName,
          email: firebaseData.email,
          provider: 'facebook',
          keys: firebaseData.keys,
          birthday: firebaseData.birthday,
          snapchat: firebaseData.snapchat,
          gender: firebaseData.gender,
          image: firebaseData.photoURL
        });

        observer.next();
      });
    }, error => {
      observer.error(error);
    });
  } else {
    this.af.auth.login({
      provider: AuthProviders.Facebook,
      method: AuthMethods.Popup,
    }).then((facebookData) => {
      console.log(facebookData);
      this.af.database.list('users').update(facebookData.auth.uid, {
        name: facebookData.auth.displayName,
        email: facebookData.auth.email,
        provider: 'facebook',
        keys: 5,
        birthday: 'w',
        snapchat: 'w',
        gender: 'male',
        image: facebookData.auth.photoURL
      });
      observer.next();
    }).catch((error) => {
      console.info("error", error);
      observer.error(error);
    });
  }
});
}

Any help would be greatly appreciated!


#2

Hello,
I am trying too get some info from the facebook. Until now i am trying to get users connect at my app through facebook but i haven’t achieve it yet. Did you done it? I have follw the docs but still no hope.