Firebase 3.2.0 - 创建用户时出现内部错误
Firebase 3.2.0 - Internal Error on Create User
我刚刚使用 Firebase 3.2.0 启动了一个新项目(Swift 2.2;iOS 9;Xcode 7.3.1)并遇到了以下错误输入无效电子邮件和弱密码时我的 authorise/signup 过程的一部分:
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.}
...我的代码如下....
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:
....
执行命中 signInWithEmail() 中的 .ErrorCodeUserNotFound 案例。然后它在 createUserWithEmail() 中命中默认情况。
从文档看来,createUserWithEmail() 函数中似乎有一个 INVALID_EMAIL 错误键可用,但是,它似乎抛出一个内部错误,而不是遇到 InvalidEmail 错误情况。
三个问题:
- 登录失败导致创建用户的流程是否可以接受?
- 错误的实际原因是什么?
- 我该如何解决?
提前致谢。
为了将来参考,我针对上述错误提出了一个错误,Firebase/Google已确认将在下一个 SDK 版本中解决。
我遇到了同样的问题,发现我什至无法通过 Firebase 控制台添加用户。
但奇怪的是,我启用而不是禁用 Google 登录,并且我能够手动添加用户。所以我尝试用 createUserWithEmail
创建一个用户并且成功了。
您可能想尝试启用和禁用使用电子邮件登录功能,这可能会以某种方式重置 Firebase 端的某些设置,从而解决问题。这 "workaround" 让我相信问题出在他们的服务器端,而不是 SDK。
检查此 post:
您可以通过在 Google 控制台上激活 Identity Toolkit API 来解决问题。
我刚刚使用 Firebase 3.2.0 启动了一个新项目(Swift 2.2;iOS 9;Xcode 7.3.1)并遇到了以下错误输入无效电子邮件和弱密码时我的 authorise/signup 过程的一部分:
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.}
...我的代码如下....
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:
....
执行命中 signInWithEmail() 中的 .ErrorCodeUserNotFound 案例。然后它在 createUserWithEmail() 中命中默认情况。
从文档看来,createUserWithEmail() 函数中似乎有一个 INVALID_EMAIL 错误键可用,但是,它似乎抛出一个内部错误,而不是遇到 InvalidEmail 错误情况。
三个问题:
- 登录失败导致创建用户的流程是否可以接受?
- 错误的实际原因是什么?
- 我该如何解决?
提前致谢。
为了将来参考,我针对上述错误提出了一个错误,Firebase/Google已确认将在下一个 SDK 版本中解决。
我遇到了同样的问题,发现我什至无法通过 Firebase 控制台添加用户。
但奇怪的是,我启用而不是禁用 Google 登录,并且我能够手动添加用户。所以我尝试用 createUserWithEmail
创建一个用户并且成功了。
您可能想尝试启用和禁用使用电子邮件登录功能,这可能会以某种方式重置 Firebase 端的某些设置,从而解决问题。这 "workaround" 让我相信问题出在他们的服务器端,而不是 SDK。
检查此 post: 您可以通过在 Google 控制台上激活 Identity Toolkit API 来解决问题。