简体   繁体   中英

Firebase: login error

EDIT: I found a similar question specific to the Facebook login. I am using email authentication but the problem / solution may be the same.


I am using the Firebase demo example class SignInViewController and it works well on the demo project. However when I try to integrate it on my own project it gives me the following error:

UserInfo={NSUnderlyingError=0x14704d4b0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={type = immutable dict, count = 3, entries => 0: {contents = "message"} = {contents = "INVALID_EMAIL"} 1: errors = {type = immutable, count = 1, values = ( 0: {type = immutable dict, count = 3, entries => 0: reason = invalid 1: message = {contents = "INVALID_EMAIL"} 2: domain = global }

)} 2: code = {value = +400, type = kCFNumberSInt64Type} } }}, error_name=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information.}

I enabled the Email login method on the console for the app.

Any idea why this is happening?

Check your settings on dev.facebook in "Login with Facebook" -> "Settings" and paste correct OAuth redirect URIs from Firebase to "Valid OAuth redirect URIs" field. Next enable your Facebook app (should be green). In code paste this:

    func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
    if error != nil {
        self.showAlert(msg: AlertMessages.facebookLoginError)
        return
    }
    if !result.isCancelled {

        let token = FBSDKAccessToken.currentAccessToken().tokenString
        let credential = FIRFacebookAuthProvider.credentialWithAccessToken(token)
        FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
            if let error = error {
                UserAuthManager.sharedInstance.logoutFromFacebook()

                if let errCode = FIRAuthErrorCode(rawValue: error.code) { // error
                }
                return
            }
            self.userDidSignedIn()
            //Logged with FB!
        }
    }
}

Remeber to set FBSDKLoginButtonDelegate in your controller.

Make sure you also enable sign in with email/password in your Firebase console.

Firebase console -> Authentication -> Sign-in method -> Enable provider Email/Password.

在 Firebase 中切换

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM