React Native Facebook Login with Auth Token

Greetings,

I’m trying to determine whether or not I can utilizing Backendless, as it has some very attractive features…

I have a React Native app that does a Facebook login via the Facebook SDK, so I have a Facebook Auth token available to me. I don’t see a Backendless Facebook login API accepting a Facebook Auth token, however, I do see API accepting a Facebook Auth token for iOS/Android. Am I missing something?

Thanks

Hello, Dennis!

No, JS SDK doesn’t have method where fb token can be passed. However, you can use LoginWithFacebookSDK() method for your purposes. Have you tried it?
regards,
Alex

I have not tried it yet. I wasn’t clear on what the value of facebookFieldMapping needed to be. Are there any examples available?

Thanks!

facebookFieldsMapping - a mapping between the Facebook fields and Backendless user properties. Keys must be the names of the Facebook fields, values - the names of the Backendless properties

This property defines mapping between Facebook user representation and table “Users” in Backendless. For example, it can look like this: {“first_name”:“name”, “email”:“email”}. Facebook properties list is available here: https://developers.facebook.com/docs/graph-api/reference/user. Backendless User properties are just columns in “Users” table.

I use the Facebook React Native SDK (https://developers.facebook.com/docs/react-native) to sign in successfully. But when I try the loginWithFacebookSDK I get the “FB is not defined” error. Not sure how to initialize the FB variable.

Any suggestions?

Since FB is not available in loginWithFacebookSDK on ReactNative, I use the Facebook React Native SDK (https://developers.facebook.com/docs/react-native) to sign in successfully to Facebook. I then tried to call the _sendSocialLoginRequest directly with my response from the Facebook authentication.

But all I get is a {message: “Could not approve social account.”, statusCode: 400}

I have successfully sign in with easyLogin on iOS before and I have successfully login with the Javascript loginWithFacebookSDK on a test website so I believe that my settings in Backendless are correct. But when I try to login with my React Native app running on Android I only get the "Could not approve social account when trying to login (using below method).

To test the _sendSocialLoginRequest directly I added a method to backendless.js

loginWithFacebookResponse: function(response, fieldsMapping, stayLoggedIn, async) {
	 
	 if (stayLoggedIn instanceof Async) {
 async = stayLoggedIn;
 stayLoggedIn = false;
 } 
 
 var socialType = "facebook";
 
 var me = this;
	me._sendSocialLoginRequest(me, response, "facebook", fieldsMapping, stayLoggedIn, async); 
},

The response i’m passing in looks like this:

{
"accessToken":"EAAMwvBghWzQBAK8GEopwDbZA7ZBvKmM78hew9QPF9QK4dLzOyzGCZCnu5KGKpA8yyKgvNVFzQzul1A2QfGn3LMSYwvP2tk8O9MXhzjYYIyCnZCydIRlAKF9ZCkwWIzEBaInHkqJrb1eMgTTTS3n0eSB8iE2SA76h3Uc0iEzf5HdovrJPuotgmpn1BWrRNBIByZAQUGudtmJwZDZD",
"permissions":["public_profile"],
"declinedPermissions":[],
"applicationID":"898009346956084",
"accessTokenSource":"WEB_VIEW",
"userID":"108658029627537",
"expirationTime":1486275991465,
"lastRefreshTime":1481091991465
}

Any chance I could get this to work with any tweaks to what I’m passing in here?
Do you have any plans to add the loginWithFacebookAccessToken method that is available on iOS native SDK to the Javascript SDK?