Facebook login in Javascript

Please help me with facebook login using javascript.
When i am trying to use facebook login from backendless,i can get the facebook login.After entering my credentials,its asking me permissions but user data is not stored in my backendless users table.
Here is the code.
$scope.facebookLogin=function(){
function callback(user){
console.log(user);
}
function gotError( err ){ // see more on error handling
console.log( "error message - " + err.message );
console.log( "error code - " + err.statusCode );
}

Backendless.UserService.loginWithFacebook(new Backendless.Async( callback, gotError ) );
I am getting error as undefined.

I am getting error as undefined.

Where do you get that error?

Hi Mark,
Thanks for the response.When i run my application,after connecting to facebook i am getting an error.When i printed that error,its showing like this.

Unable to register user. Property ‘email’ is required

Hi Mark,

Can you please help me with my problem as soon as possible because i am in middle of the project.

Harish,

As much as I would love to help, I cannot do it as a developer would need to look into it.

Have you configured your facebook app as described here?:
https://backendless.com/documentation/manage/mgmt_social_settings.htm

Mark

Ya i have done all configurations like adding facebook appid and secret key in backendless. Added the redirect url in my app in facebook developers page. Enabled OAuth settings.I think the problem is with the backendless api call.

can you please tell me whether this api call is correct or not.

Backendless.UserService.loginWithFacebook(new Backendless.Async( callback, gotError ) );

Hi Mark,

I fixed that problem.But,after making an api call,i am getting an error in console.Here is the screenshot of that error.My code is like this…

$scope.facebookLogin=function(){

function callback(user){
console.log(user);
}

function gotError( err ){ // see more on error handling
console.log(err);
console.log( "error message - " + err.message );
console.log( "error code - " + err.statusCode );
}

var facebookFieldsMapping =
{
“email” : “email”
}

Backendless.UserService.loginWithFacebook(new Backendless.Async(facebookFieldsMapping, callback));
}

Hi, Harish,

It’s because of the first argument of Backendless.Async is an object, but it waiting for a function to call it after success response.

Try next call:

Backendless.UserService.loginWithFacebook(facebookFieldsMapping, permissions, new Backendless.Async(callback, gotError));

where:

permissions = "email";
facebookFieldsMapping = {email:"email"};

It should work well.

Regards,
Stanislav

Hi Stanislav Yashchenko,

Thank you for the help.It’s working.

Regards,

Harish