Reputation: 60
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:
Is there anything else I need to do in facebook or firebase setting or there is something wrong with my code?
Upvotes: 1
Views: 1666
Reputation: 26
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!
Upvotes: 1