You storage security rules probably have an
allow write: if request.auth !=null
clause and here you don't seem to be using FirebaseAuth to authenticate the user.
For testing, is suggest you use signInAnonymously() method and sign the user transparently before writing to the storage.
FirebaseAuth mAuth = FirebaseAuth.getInstance();
Then in sign in before doing any of the stuff that you are doing
FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
// do your stuff
} else {
signInAnonymously();
}
signInAnonymously() method is as follows
private void signInAnonymously(){
mAuth.signInAnonymously().addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override public void onSuccess(AuthResult authResult) {
// do your stuff
}
}) .addOnFailureListener(this, new OnFailureListener() {
@Override public void onFailure(@NonNull Exception exception) {
Log.e("TAG", "signInAnonymously:FAILURE", exception);
}
});
}
Also in the Firebase console, under authentication> signin methods, enable anonymous sign in
This may solve your problem
Alternatively if you don't want authentication for testing have the rules as:
allow write: if true;
DO THIS ONLY FOR TESTING AS THIS IS BASICALLY PUBLIC ACCESS
Then you can adjust your authentication approach according to your rules.
If your rules are not what i specified, please share your rules so that we can guide you accordingly rather than speculating and guessing
You storage security rules probably have an
allow write: if request.auth !=null
clause and here you don't seem to be using FirebaseAuth to authenticate the user.
For testing, is suggest you use signInAnonymously() method and sign the user transparently before writing to the storage.
FirebaseAuth mAuth = FirebaseAuth.getInstance();
Then in sign in before doing any of the stuff that you are doing
FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
// do your stuff
} else {
signInAnonymously();
}
signInAnonymously() method is as follows
private void signInAnonymously(){
mAuth.signInAnonymously().addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override public void onSuccess(AuthResult authResult) {
// do your stuff
}
}) .addOnFailureListener(this, new OnFailureListener() {
@Override public void onFailure(@NonNull Exception exception) {
Log.e("TAG", "signInAnonymously:FAILURE", exception);
}
});
}
Also in the Firebase console, under authentication> signin methods, enable anonymous sign in
This may solve your problem
Alternatively if you don't want authentication for testing have the rules as:
allow write: if true;
**DO THIS ONLY FOR TESTING AS THIS IS BASICALLY PUBLIC ACCESS**
Then you can adjust your authentication approach according to your rules.
If your rules are not what i specified, please share your rules so that we can guide you accordingly rather than speculating and guessing