我收到消息=“ ADMIN_ONLY_OPERATION”的运行时错误;在使用以下代码时

时间:2019-09-07 06:29:27

标签: ios swift firebase google-cloud-firestore firebase-authentication

我正在运行一个聊天应用代码,它给了我身份验证运行时错误。错误消息如下所示。 我尝试了几件事,但仍未解决,如果您需要其他与​​代码相关的信息,请告诉我。

提前感谢

代码是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";
}}}}

2 个答案:

答案 0 :(得分:4)

确保已在Firebase控制台中启用了匿名登录。看一下图片并启用标记的开关。您可以找到Firebase控制台here

答案 1 :(得分:3)

除了Constantin Beer's答案(即从firebase启用匿名登录方法)之外,google还注册了此新的beta功能(身份平台),您需要在其中选中启用创建(注册)功能选项。在文档中还没有提到这一点,Alex Kozlowski花了很多时间来解决这个问题。请参考下图

enter image description here

相关问题