loginWithFacebook with Javascript - FB ID showing up in Email field in User Table

I am using BK Cloud 3.0. I am using javascript SDK.

When user logs in using Facebook the email field in the backendless user database has the facebook ID instead of the users email address. (see attached).

I can reproduce this using the generate code.

capture20170529131550170.png

Hi Barry,

This is the expected behaviour since Facebook does not share the user’s email by default. You should specify the mapping for it and ask for a permission when registering a user, you can find more info on this in our docs.

Thank you for the info. Now I am getting an error following the example on the REST doc page for Facebook. Console.log

POST https://api.backendless.com/v1/users/social/oauth/facebook/request_url 400 (Bad Request)
userprice.js:107 error message - External authentication failed with message ‘Can not parse scope from request body’
userprice.js:108 error code - 400

$('#fb_login').on('click', function () {
            var fieldsMapping = {
                "email": "email",
                "first_name": "firstname",
                "last_name": "lastname"
            }


            var permissionsMapping = {
                "permissions": ["email"]
            }


            Backendless.UserService.loginWithFacebook(fieldsMapping, permissionsMapping, new Backendless.Async(userLoggedInStatus, gotError), true);
        });

I was able to get email from facebook login using this code:

$('#fb_login').on('click', function () { 
var fieldsMapping = { "email": "email", "first_name": "firstname", "last_name": "lastname" }; 
var permissionsMapping = ["email"]; 


Backendless.UserService.loginWithFacebook(fieldsMapping, permissionsMapping, new Backendless.Async(userLoggedInStatus, gotError), true); 
});

I suppose that’s because you were using an object instead of array. The example in the docs specifies this property as an array, so it’s not clear why you chose to make it an object.
Anyway, glad your problem is solved now :slight_smile: