Firebase 3.2.0 - Internal Error on Create User

戏子无情 提交于 2019-12-04 13:42:24

问题


I've just kicked off a new project (Swift 2.2; iOS 9; Xcode 7.3.1) using Firebase 3.2.0 and have hit the following error as part of my authorise/signup process when entering both an invalid email and a weak password:

NSError

Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and 
inspect the error details for more information." UserInfo={error_name=ERROR_INTERNAL_ERROR, 
NSUnderlyingError=0x7c0549a0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" 
UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey=<CFBasicHash 0x7c04bd90 [0x1a701f8]>
{type = immutable dict, count = 3,
entries =>
0 : <CFString 0x7c0fb0c0 [0x1a701f8]>{contents = "errors"} = 
<CFArray 0x7c0713a0 [0x1a701f8]>{type = immutable, count = 1, values = (
0 : <CFBasicHash 0x7c0fac00 [0x1a701f8]>{type = immutable dict, count = 3,
entries =>
0 : <CFString 0x7c051080 [0x1a701f8]>{contents = "reason"} = 
<CFString 0x7c0553f0 [0x1a701f8]>{contents = "invalid"}
1 : <CFString 0x7c055f30 [0x1a701f8]>{contents = "message"} = 
<CFString 0x7c061580 [0x1a701f8]>{contents = "INVALID_EMAIL"}
2 : <CFString 0x7c054fd0 [0x1a701f8]>{contents = "domain"} = 
<CFString 0x7c060290 [0x1a701f8]>{contents = "global"}
}

)}
1 : <CFString 0x7c05aae0 [0x1a701f8]>{contents = "code"} = 
<CFNumber 0x7c073010 [0x1a701f8]>{value = +400, type = kCFNumberSInt64Type}
2 : <CFString 0x7c067e70 [0x1a701f8]>{contents = "message"} = 
<CFString 0x7c0543a0 [0x1a701f8]>{contents = "INVALID_EMAIL"}
}
}}, NSLocalizedDescription=An internal error has occurred, print and inspect the error 
details for more information.}

...and my code is as follows....

AuthViewController.swift

if let email = emailField.text where email != "", let password = passwordField.text where 
  password != "" {FIRAuth.auth()?.signInWithEmail(email, password: password) { (user, error) in
    if let error = error {
            if let errorCode = FIRAuthErrorCode(rawValue: error.code) {
                switch errorCode {
                case .ErrorCodeNetworkError:
                    print("A network error occurred")
                case .ErrorCodeUserNotFound:
                    print("ATTEMPTING TO CREATE USER")
                    FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in
                        if let error = error {
                            if let errCode = FIRAuthErrorCode(rawValue: error.code) {
                                switch errCode {
                                case .ErrorCodeInvalidEmail:
                                    print("invalid email")
                                case .ErrorCodeWeakPassword:
                                    self.insertErrorLabel("Password is considered weak (< 6 characters). Try again")
                                default:
                                    print("Create User Error: \(error)")
                                }
                            }
                        } else {
                            // create a user in the database...
                        }
                    }
                case .ErrorCodeUserTokenExpired:

                ....

Execution hits the .ErrorCodeUserNotFound case in signInWithEmail(). It then hits the default case in createUserWithEmail().

From the docs it appears as though there's an INVALID_EMAIL error key available in the createUserWithEmail() function, however, it appears to be throwing an internal error rather than hitting the InvalidEmail error case.

Three questions:

  1. Do I have an acceptable flow here with signIn failure leading to createUser?
  2. What's the actual cause of the error?
  3. How can I address it?

Thanks in advance.


回答1:


For future reference, I raised a bug for the above error and Firebase/Google have confirmed it will be addressed in the next release of the SDK.




回答2:


I had the same problem and noticed that I wasn't even able to add a user through the Firebase console. Strangely, though, I enabled than disabled Google login, and I was able to manually add a user. So I tried to create a user with createUserWithEmail and it worked.

You may want to try enabling and disabling the login with email feature, which may somehow reset some settings on the Firebase side which fixes the issue. This "workaround" leads me to believe that the issue was on their server side and not SDK.




回答3:


Checkout this post: https://stackoverflow.com/a/38076718 You can solve the problem by activating the Identity Toolkit API on Google Console.



来源:https://stackoverflow.com/questions/37330086/firebase-3-2-0-internal-error-on-create-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!