首页 > 解决方案 > 我收到消息 =“ADMIN_ONLY_OPERATION”的运行时错误;在使用下面的代码时

问题描述

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

提前致谢

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

标签: iosswiftfirebasegoogle-cloud-firestorefirebase-authentication

解决方案


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


推荐阅读