1

I'm trying to set up Facebook sign-in to my app using Firebase. When I'm trying to sign in with facebook credential using firebase I'm getting this error:

*Failed to sign up with error:* Remote site 5XX from facebook.com for VERIFY_CREDENTIAL

where the first part of this string (the one between *) is not part of the error but I added it in a print to find out where exactly I get this error. Here's the code snippet to make this clearer.

// MARK: Sign in with Facebook
static func signInWithFacebook(in viewController: UIViewController, completion: @escaping (_ message: String, _ error: Error?, _ sparkUser: SparkUser?) ->()) {
    let loginManager = LoginManager()
    loginManager.logIn(permissions: [.publicProfile, .email], viewController: viewController) { (result) in
        switch result {
        case .success(granted: _, declined: _, token: _):
            print("Succesfully logged in into Facebook.")
            self.signIntoFirebaseWithFacebook(completion: completion)
        case .failed(let err):
            completion("Failed to get Facebook user with error:", err, nil)
        case .cancelled:
            completion("Canceled getting Facebook user.", nil, nil)
        }
    }
}

// MARK: Sign into Firebase with Facebook
fileprivate static func signIntoFirebaseWithFacebook(completion: @escaping (_ message: String, _ error: Error?, _ sparkUser: SparkUser?) ->()) {
    guard let authenticationToken = AccessToken.current?.tokenString else {
        completion("Could not fetch authenticationToken", nil, nil)
        return
    }
    let facebookCredential = FacebookAuthProvider.credential(withAccessToken: authenticationToken)
    signIntoFirebase(withFacebookCredential: facebookCredential, completion: completion)
}

fileprivate static func signIntoFirebase(withFacebookCredential facebookCredential: AuthCredential, completion: @escaping (_ message: String, _ error: Error?, _ sparkUser: SparkUser?) ->()) {
    Auth.auth().signIn(with: facebookCredential) { (result, err) in
        // Here I get the error
        if let err = err { completion("Failed to sign up with error:", err, nil); return }
        print("Succesfully authenticated with Firebase.")
        self.fetchFacebookUser(completion: completion)
    }
}

Before getting the error the string "Succesfully logged in into Facebook." is printed out but after that I get the error mentioned before. I followed the steps of Firebase guidelines and I also alredy checked different things:

  • my keys (ID app and secret key) are the same in my facebook app configuration than in my firebase facebook auth mode
  • the app is still "under developing" and so I'm testing the login by using my Administrator profile
  • App Secret embedded in the client is already turned off. This solution was provided in a similar problem
  • I checked the steps of the facebook login configuration (correct bundle ID, single sign on, info.plist config, appdelegate)
  • Firebase SDK configuration (google.plist, appdelegate)

Is there anything else I need to do in facebook or firebase setting or there is something wrong with my code?

Luigi Loria
  • 40
  • 1
  • 5
  • More info about the error I'm getting: Optional(Error Domain=FIRAuthErrorDomain Code=17004 "Remote site 5XX from facebook.com for VERIFY_CREDENTIAL" UserInfo={NSLocalizedDescription=Remote site 5XX from facebook.com for VERIFY_CREDENTIAL, FIRAuthErrorUserInfoNameKey=ERROR_INVALID_CREDENTIAL}) – Luigi Loria Apr 16 '21 at 18:49

1 Answers1

1

The Unity SDK was also a problem for me, and finally, I found a solution.

Check this link. github issue

In the last post, I deleted my application and then created a new application, but changed the application type and it worked!

image

  • Thanks for trying to help, but now the options are a bit different and I don't remember which option I've chosen, do you know where I can see it? In any case, which option should I try between "consumer" and "gaming"? [image] (https://prnt.sc/11pbehw) – Luigi Loria Apr 19 '21 at 13:29
  • 1
    Choose "consumer" – Wei Cheng Su Apr 20 '21 at 01:35