我正在运行聊天应用程序代码,它给了我身份验证运行时错误。错误消息如下所示。 我尝试了几件事,但还没有解决,如果您需要其他代码相关信息,请告诉我。
提前致谢
代码是AppDelegate.Swift文件
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Auth.auth().signInAnonymously { (authUser, error) in
guard Auth.auth().currentUser != nil else {
print(error!)
abort()
}
self.uid = Auth.auth().currentUser!.uid
UserDefaults.standard.set(Auth.auth().currentUser!.uid, forKey: "uid")
let user = User(id: Auth.auth().currentUser!.uid, name: "ぼく")
UserRepository.shared.save(user)
}
return true
}
错误信息
Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x6000016744b0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={
code = 400;
errors = (
{
domain = global;
message = "ADMIN_ONLY_OPERATION";
reason = invalid;
}
);
message = "ADMIN_ONLY_OPERATION";
}}}}
确保您已在 Firebase 控制台中启用匿名登录。看一下图片并启用标记的开关。您可以在此处找到 Firebase 控制台。
除了 Constantin Beer 的答案(即从 firebase 启用匿名登录方法)之外,谷歌还注册了这个新的测试版功能(身份平台),您需要在其中选中启用创建(注册)选项。文档中尚未提到这一点,Alex Kozlowski 花了很多时间来解决这个问题。请参考下图
我做了同样的事情并标记了启用,但它仍然给我无法验证用户:Error Domain = FIRAuthErrorDomain Code = 17085“ADMIN_ONLY_OPERATION”UserInfo = {NSLocalizedDescription = ADMIN_ONLY_OPERATION,FIRAuthErrorUserInfoNameKey = ERROR_ADMIN_RESTRICTED_OPERATION}