signInAnonymously:FAILURE com.google.firebase.auth.FirebaseAuthException: despite Anonymous Sign in enabled

Viewed 174

Despite I have enabled in my Firebase project anonymous sign in, my mobile (Android) app is not able to authenticate and I'm getting this error (on emulator and on physical device too).

signInAnonymously:FAILURE com.google.firebase.auth.FirebaseAuthException: This operation is restricted to administrators only.

My Firebase config:

enter image description here

My code:

   mAuth = FirebaseAuth.getInstance();
...
 // Sign in anonymously. Authentication is required to read or write from Firebase Storage.
    mAuth
        .signInAnonymously()
        .addOnSuccessListener(
            mActivity,
            authResult -> {
              Log.d(TAG, "signInAnonymously:SUCCESS");
              try {
                upload();
              } catch (Exception e) {
                Log.e(TAG, "upload:FAILURE", e);
              }
            })
        .addOnFailureListener(
            mActivity,
            exception -> {
              Log.e(TAG, "signInAnonymously:FAILURE", exception);
            });
  }

Dependencies:

 implementation 'com.google.firebase:firebase-auth:21.0.1'
 implementation 'com.google.firebase:firebase-storage:20.0.0'
 implementation "com.google.firebase:firebase-core:18.0.2"

Does anybody had the same problem?

1 Answers

Well, in the end, I updated packages to this:

+    implementation platform('com.google.firebase:firebase-bom:29.0.2')
+    implementation 'com.google.firebase:firebase-auth'
+    implementation 'com.google.firebase:firebase-storage'

...  implementation "com.google.firebase:firebase-core:18.0.2" //not updated

Make the Firebase storage rules look like this(disclaimer: for my debug version, production I suppose will be more strict):

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
    allow read, write;
    }
  }
}
​

And it started to work. But honestly not sure why ¯\(ツ)/¯.

Related