8 ios firebase swift firebase-authentication google-cloud-firestore
我正在运行聊天应用程序代码,它给了我身份验证运行时错误。错误信息如下所示。我尝试了几件事,但没有任何结果,如果您需要其他与代码相关的信息,请告诉我。
提前致谢
代码是 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
}
Run Code Online (Sandbox Code Playgroud)
错误信息
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";
}}}}
Run Code Online (Sandbox Code Playgroud)
除了Constantin Beer 的 回答(即启用来自 firebase 的匿名登录方法)之外,谷歌还注册了这个新的测试版功能(身份平台),您需要在其中选中启用创建(注册)选项。文档中还没有提到这一点,Alex Kozlowski花了很多时间来解决这个问题。请参考下图
| 归档时间: |
|
| 查看次数: |
1643 次 |
| 最近记录: |