FirebaseExtended / angularfire

AngularJS bindings for Firebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migration to SDK 3: facebook login missing user data

KixS opened this issue · comments

commented

Hello,

I am migrating my app from AngularFire1/Firebase2 to AngularFire2/Firebase3 and I have some issues with the facebook login.

I am missing most of the signed-in user info.

Here is the request I am submitting:

providerAuth = new firebase.auth.FacebookAuthProvider();
providerAuth.addScope('public_profile');
Auth.$signInWithPopup(providerAuth).then(function(authData) {
    userInfo = authData.user.providerData[0];
})

In userInfo, I get only:

  • displayName
  • email
  • photoURL
  • providerId
  • uid

While with AngularFire1/SDK2

Auth.authWithOAuthPopup('facebook', function(error, authData) {
    userInfo = authData.facebook.cachedUserProfile;
})

This would get me in addition:

  • first_name
  • last_name
  • gender
  • age_range
  • locale

Am I missing something or am I not looking at the right place ?

Pretty sure you need to add the appropriate scopes. See step 2 here for an example and link to the FB docs on scopes.

This is actually unfortunately a change in the behavior of the API, although we should be reintroducing provider data like this in an upcoming release. You do need set the appropriate scopes, as Kato suggests, but that will only get you a Facebook access token with the right scpoes which you can then use to request profile data from the Facebook Open Graph. The 3.x.x SDKs do not currently return that data to you. See the Facebook docs here for how to do this. It should be a single request to https://graph.facebook.com/me/ with you Facebook access token.

commented

Thanks @katowulf and @jwngr :)

commented

Hi again,

I am assuming it is the same for google login. However I just can't seem to recover the email of the user.

Here is what I am doing:

providerAuth = new firebase.auth.GoogleAuthProvider();
providerAuth.addScope('https://www.googleapis.com/auth/userinfo.email');
providerAuth.addScope('https://www.googleapis.com/auth/userinfo.profile');
providerAuth.addScope('email');
providerAuth.addScope('profile');
Auth.$signInWithPopup(provider).then(function(authData) {
    $http.get("https://www.googleapis.com/oauth2/v1/userinfo?access_token="+authData.credential.accessToken).then(function(result) {
    })
})

Neither the object returned by signInWithPopup nor the one returned by the googleapi request contains the email of the user. Actually:

  • 'signInWithPopup' returns a null for email
  • 'https get' does not return email while it returns familyname, givenname, gender...

Any idea why ? Not sure if I'm adding the right scopes :/