3

I want to use Firebase Storage (web version 9.6.0) but the access to Firebase Storage is being denied with the following error:

unhandledRejection: FirebaseError: Firebase Storage: User is not authenticated, please authenticate using Firebase Authentication and try again. (storage/unauthenticated)

You would want to say to me that I just need the user to be authenticated, but two problems:

  • the user is already authenticated (getAuth().currentUser returns something)

  • the rules in Firebase Storage don't say that a user needs to be authenticated:

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

The problem is caused when I try this:

// initializeApp(config) etc.

const storage = getStorage() // enabled in Firebase console
const a_correct_path = "something..."
const reference = ref(storage, a_correct_path) // this is working (I get the right reference)
const url = getDownloadURL(reference) // this throws the error

NOTE: Because I have already had problems with it, please not that I'm using App Check which I have enforced for the Storage feature.

Why did I do wrong?

ThomasG2201
  • 676
  • 6
  • 25

2 Answers2

0

Firstly, The

const a_correct_path = ""

Can't be empty and should have the correct path if it's in a folder.

But if that doesn't help... Reset your storage rules to the first one.

If that doesn't work, check the line where you imported things from firebase

Timileyin
  • 126
  • 2
0

On the Firebase Console, go to Authentication. Check that the user that you are logged in with appears there. If the user is not there then that means you are not authenticating users with Firebase Authentication, and maybe you're just adding users to your Firestore. That is why the error is placing emphasis on Firebase Authentication.

User is not authenticated, please authenticate using Firebase Authentication and try again.

Julian Castro
  • 109
  • 1
  • 5