Firebase storage/unauthorized due to Storage Rule

Hello Group,

My dev has run into Firebase Phone Auth error:

I use this plugin to Phone auth https://ionicframework.com/docs/native/firebase-authentication. So how can I transfer that Auth details to the AngulraFireAuth?

Original

I have a Firebase Storage bucket permission like so:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write:if request.auth != null;
    }
  }
}

Client-side code: i.e. upload an image

 console.log('user', await this.afAuth.currentUser); //null

 const filePath: string = `signatures/${user.uid}`;

 const afUploadTask: AngularFireUploadTask = afStorageReference.putString(imageDataUrl, 'data_url');

But it fails:

vendor.js:44100 ERROR Error: Uncaught (in promise): FirebaseStorageError: {ā€œcode_ā€:ā€œstorage/unauthorizedā€,ā€œmessage_ā€:ā€œFirebase Storage: User does not have permission to access ā€˜signatures/gx3TlaSFQoPhQXCnjk3QCrq2j9x1ā€™.ā€,ā€œserverResponse_ā€:ā€œ{\n "error": {\n "code": 403,\n "message": "Permission denied. Could not perform this operation"\n }\n}ā€,ā€œname_ā€:ā€œFirebaseErrorā€}

So how can I configure this kind of rule with Storage? Without any rule above code is working fine.

Here is the link to the above:

Any help would be much appreciated

1 Like

@mhartington would really appreciate your help hereā€¦

We are on an Ionic app and are using a plugin to authenticate the user through the native iOS/android SDKs but we are trying to handle the interaction with Storage or Firestore through the web SDK. I donā€™t know if that works, but at the moment we getting the above errorā€¦

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

add this in firebase->storage->rules

1 Like