我收到 message = "ADMIN_ONLY_OPERATION"; 的运行时错误;使用以下代码时

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)

Con*_*eer 11

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

  • 是的,它确实有效,但还有一些问题,但与此无关。 (2认同)

Vij*_*mar 5

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

在此处输入图片说明