Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a user's email address using accounts-facebook in Meteor?

I created a Meteor app that allows users to sign on using Facebook. To do this, I'm using the accounts-ui and accounts-facebook packages. This works fine.

How do I retrieve the user's email address once they've signed on? I understand that this requires special permission, and so I added email as a "User & Friend's Permission" in the app settings on the Facebook developers site. Following the Meteor documentation, I also set up Account.ui.config like this:

Accounts.ui.config({
  requestPermissions: {
    facebook: ['email'],
  },
  passwordSignupFields: 'USERNAME_AND_EMAIL'
});

As expected, when a user of my app signs on using Facebook, it correctly asks them to share their email address. But how do I retrieve it? The user document has only the _id and profile.name.

like image 314
JWS Avatar asked Dec 18 '12 08:12

JWS


1 Answers

The Facebook user's email address is stored in [userDocument].services.facebook.email, which is not published to the client, but can be accessed from the server or from the client using Meteor.methods and Meteor.call.

like image 177
JWS Avatar answered Sep 19 '22 06:09

JWS