javascript - Get email with Facebook Firebase Simple Login -



javascript - Get email with Facebook Firebase Simple Login -

using facebook firebase simple login. trying person's real name, have done via user.displayname in firebasesimplelogin instance. when seek getting email user.email, returns undefined. have done same thing google+ , works fine, no undefineds returned. here code:

var chatref = new firebase('https://******.firebaseio.com'); //no, didn't set firebase name in code =p var auth = new firebasesimplelogin(chatref, function(error, user) { if (error) { // error occurred while attempting login console.log(error); alert('an error occurred while trying log in.' + error); } else if (user) { // user authenticated firebase console.log('name: ' + user.displayname + ', email: ' + user.email); //with google, 'name: john doe, email: johndoe@example.com' returned //with facebook, 'name: john doe, email: undefined' returned } else { // user logged out } }); function google() { auth.login('google', { rememberme: true }); } function facebook() { auth.login('facebook', { rememberme: true, scope: 'email' }); }

so, question is, how can user's email address facebook firebase simple login? give thanks in advanced.

before start, best way see properties exist on user object add together console log existing auth check.

using:

else if (user){ console.log(user); }

you'll know properties exist on user object have set currently. additional permission might required - see below.

per facebook dev docs, permissions strings passed along login request or api call. here 2 examples of permissions:

email: access person's primary email address. user_likes: access list of things person likes.

for example, if add together login button web app , inquire email , user_likes via scope parameter, person prompted dialog when logging in first time:

and per firebase docs

here illustration session stored 30 days (due 'remember me' setting), , request extended permissions email , user_likes:

auth.login('facebook', { rememberme: true, scope: 'email,user_likes' });

so, unless have added additional permissions in auth.login parameters, not able access user's primary email address.

javascript facebook google-plus firebasesimplelogin

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -