Backendless Support
 
Solved

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.

Leave a Comment

Comments (4)

photo
1

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.

photo
1

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

  1. $('#fb_login').on('click', function () {
  2. var fieldsMapping = {
  3. "email": "email",
  4. "first_name": "firstname",
  5. "last_name": "lastname"
  6. }
  7. var permissionsMapping = {
  8. "permissions": ["email"]
  9. }
  10. Backendless.UserService.loginWithFacebook(fieldsMapping, permissionsMapping, new Backendless.Async(userLoggedInStatus, gotError), true);
  11. });

photo
1

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

  1. $('#fb_login').on('click', function () {
  2. var fieldsMapping = { "email": "email", "first_name": "firstname", "last_name": "lastname" };
  3. var permissionsMapping = ["email"];
  4. Backendless.UserService.loginWithFacebook(fieldsMapping, permissionsMapping, new Backendless.Async(userLoggedInStatus, gotError), true);
  5. });

photo
1

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 :)