Search code examples
iosswiftfirebasegoogle-cloud-firestorefirebase-authentication

I am getting the runtime error of message = "ADMIN_ONLY_OPERATION"; while using the below code


I am running a chat app code , it is giving me the authentication runtime error. Error message is shown below. I tried several things but nothing worked out yet, if you need another code related information do let me know.

thanks in advance

the code is AppDelegate.Swift file

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 Message

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";
}}}}

Solution

  • Make sure you have enabled the Anonymous login in your Firebase Console. Take a look at the picture and enable the marked switch. You can find the Firebase Console here.