Facebook SDK issue with version 4.0

I also remember that with the Backendless 3.0 there was an issue with Facebook Login if we had a version of the FB SDK after version 4.15.1. Do you know if that has been fixed in Backendless 4.0?

We have validated that Login with Facebook works with the latest Backendless SDK for iOS. We tested it with Facebook SDK 4.22.0. The documentation describing “login with facebook” is at:
https://backendless.com/docs/ios/doc.html#users_facebook_login

Regards,
Mark

I am testing the FB SDK version 4.22.0 and it is having the same issue as when I tried it last time. The access token is coming up as nil. Do you have the sample project that you used to test the latest version of the FB SDK? There doesn’t seem to be much change between version 3.0 and 4.0 in terms of code for FB login am I correct?

If access token is coming up as nil, it is an issue with Facebook SDK, there would be no Backendless calls at that time - integration with Backendless starts only when you already have a token from Facebook.

Please keep in mind that the “easy login” is no longer supported.

Regards,
Mark

We are not using the easy login. Once we downgrade to version 4.15.1, the token is no longer nil.

Do you have a sample project that you are using to test it? That would be really helpful to get it setup.

No, I do not have a sample project. Once again, if you do not get a token, it is not a Backendless issue. A token is created by Facebook and the code for that is entirely on the Facebook side (client SDK and/or server). Please contact Facebook support to get help with their SDK.

With version 4.15.1 we are getting an access token but when we try to login to Facebook using this code, it is not working. We are also doing this in App Delegate function. Do you have any thoughts on what it might be? I have included our code here along with the indications where we are getting an error.

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool{
let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String
let annotation = options[UIApplicationOpenURLOptionsKey.annotation]
let result = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: sourceApplication, annotation: annotation)
if result {
let token = FBSDKAccessToken.current()
let fieldsMapping = [ 
"id" : "facebookId", 
"name" : "name", 
"birthday": "birthday", 
"first_name": "firstName", 
"last_name" : "lastName", 
"gender": "gender", 
"picture":"picture", 
"email": "email" ]
let thePermissions = ["user_friends", "email", "public_profile", "contact_email"]
backendless!.userService.login(withFacebookSDK: token, permissions: thePermissions, fieldsMapping: fieldsMapping, response: { (user: BackendlessUser?) -> Void in
//Our code here for success 
}, error: { (fault: Fault?) -> Void in
//This is where we are getting an error saying:
//Optional(FAULT = '3038' [Some of required parameters are null] <Some of required parameters are null> )




})

What happens with the latest version of Facebook SDK?

With the latest version of the SDK, the token just comes back as nil before any of the other code has an opportunity to execute. FBSDKAccessToken.current() == nil

let token = FBSDKAccessToken.current()

And if you create a brand new project - no Backendless, just the Facebook SDK pod, do you get the same problem?

So I just finished isolating the FB login logic to a single project and I am still getting the same error from backendless saying “Optional(FAULT = ‘3038’ [Some of required parameters are null] <Some of required parameters are null> )”

I am now using the FB Swift SDK version 0.2.0

I can share the code with you but because it has my app id, secret and fb token etc. I can’t share it publicly. How would you like me to share it with you? Here is the main part of the code. Instead of doing this in the app delegate I have moved it into the ViewController. I have also used the swift version of the FB SDK but that shouldn’t make a difference as long as it gets the access token which it is doing. There error is coming after the backendless!.userService.login message. Are we forgetting to pass a piece of data in?







p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12f1b}
span.s1 {font-variant-ligatures: no-common-ligatures; color: #ba2da2}
span.s2 {font-variant-ligatures: no-common-ligatures; color: #000000}
span.s3 {font-variant-ligatures: no-common-ligatures}
span.s4 {font-variant-ligatures: no-common-ligatures; color: #31595d}
span.s5 {font-variant-ligatures: no-common-ligatures; color: #4f8187}
span.s6 {font-variant-ligatures: no-common-ligatures; color: #703daa}
span.s7 {font-variant-ligatures: no-common-ligatures; color: #d12f1b}
span.s8 {font-variant-ligatures: no-common-ligatures; color: #3e1e81}



let token = FBSDKAccessToken.current()

                let tokenString = FBSDKAccessToken.current().tokenString

                let userId: String = (token?.userID)!

                let expirationDate : Date = token!.expirationDate

                

                let fieldsMapping = [

                    "id" : "facebookId",

                    "name" : "name",

                    //"birthday": "birthday",

                    "first_name": "firstName",

                    "last_name" : "lastName",

                    "gender": "gender",

                    //"picture":"picture",

                    "email": "email"

                ]

                

                if let permissions = token?.value(forKey: "permissions") {

                    print("ACCOUNT PERMISSIONS: \(permissions)")

                }

                let thePermissions = ["user_friends", "email", "public_profile", "contact_email"]




                backendless!.userService.login(withFacebookSDK: userId, tokenString: tokenString, expirationDate: expirationDate, fieldsMapping: fieldsMapping, response: { (user: BackendlessUser?) -> Void in

                    

                    print("user: \(user!.email)\n[\(user!.retrieveProperties())]")

                    

                    }, error: { (fault: Fault?) -> Void in

                        print ("hellllllo1 \(fault)")

                })

Please zip up the project directory and upload it to either google drive or dropbox and send the link for the file to support@backendless.com. Do not send the file as attachment.

Please make sure to include the link for this topic in the email message.

Regards,
Mark

Perfect. I just sent that over. Once the issue is resolved, I can post the project here so everyone else has access to it as well.

Thanks. I created an internal ticket for tracking purposes. The ticket number is BKNDLSS-14506 if you need to inquire about it. Please do not delete the uploaded file as the developer will be downloading it some time tomorrow.

Regards,
Mark

Hello Nevin,
I’ve checked your project with your app and with another one and everything works fine (screenshots attached). Unfortunately I can’t reproduce this problem.

Regards, Olga

Screen Shot 2017-04-24 at 10.48.54.png

I have just shared a video of the error that I am getting when I try to log in. Did you make any changes to the code at all when testing it with our account?

Is it an issue with my facebook account? I tried using two different facebook accounts and both are returning the same problem.

Could you try the following?:

  • remove user account from the backendless app
  • unauthorize the app in the facebook console

essentially, going through the process as a brand new user.

I just tried that and sent you a video of that process as well. I removed my user account from the Users table in Backendless and I removed unauthorized the app from Facebook through the settings on my Facebook page.

Could you copy the entire output from Xcode and paste here?

Also, please take screenshots of the app settings (showing everything you configured) in Facebook and post here.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}

objc[66165]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (----------) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (----------). One of the two will be used. Which one is undefined.

2017-04-24 10:59:10.960 LookFBLogin[66165:1286043] Falling back to loading access token from NSUserDefaults because of simulator bug

2017-04-24 10:59:10.963 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

2017-04-24 10:59:10.964 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

2017-04-24 10:59:10.964 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

2017-04-24 10:59:11.075750-0400 LookFBLogin[66165:1286043] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/nevinjethmalani/Library/Developer/CoreSimulator/Devices/----------/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles

2017-04-24 10:59:11.076689-0400 LookFBLogin[66165:1286043] [MC] Reading from private effective user settings.

2017-04-24 10:59:30.417 LookFBLogin[66165:1286043] -canOpenURL: failed for URL: “fbauth2:/” - error: “The operation couldn’t be completed. (OSStatus error -10814.)”

2017-04-24 10:59:30.419 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

2017-04-24 10:59:30.421 LookFBLogin[66165:1286043] -canOpenURL: failed for URL: “fbauth2:/” - error: “The operation couldn’t be completed. (OSStatus error -10814.)”

2017-04-24 10:59:38.476 LookFBLogin[66165:1286043] Falling back to loading access token from NSUserDefaults because of simulator bug

2017-04-24 10:59:38.476 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

2017-04-24 10:59:38.844 LookFBLogin[66165:1286043] Falling back to storing access token in NSUserDefaults because of simulator bug

Logged in!

ACCOUNT PERMISSIONS: {(

email,

"public_profile",

"user_friends"

)}

Error with backendless Login: Optional(FAULT = ‘3038’ [Some of required parameters are null] <Some of required parameters are null> )