somerandomusername
somerandomusername

Reputation: 2023

Permission problems for Firebase storage, can't download file from admin panel

I'm uploading files from my node application to firebase storage. I created new Service Account user with key. Uploading works perfectly, but I cant download any files from Firebase Admin panel. Get error response:

{
  "error": {
    "code": 401,
    "message": "Unauthorized.  Could not perform this operation. "
  }
}

I am logged in with my primary gmail account (that is the owner of Firebase) I thought it should have access to every resource. These are my permission settings that I have tried:

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

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

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

None of them helped me get the permission.

Upvotes: 2

Views: 3266

Answers (2)

Max
Max

Reputation: 872

I had the same "Unauthorized" error. At some point, our app couldn't download any data from our Firebase. In our case, it was insufficient funds on the Google Cloud Platform account because Firebase takes money if your plan is Blaze. Go to the Billing page of your GCP and check it out. Right after adding money to our GCP contact, downloads started to work as usual! Screenshot: Firebase - unauthorized

Upvotes: 0

katfang
katfang

Reputation: 2030

Downloading files through the Firebase Console relies on your permissions on the GCS bucket as a developer, whereas the Rules only specify access as a user authenticated through Firebase Authentication.

You can check your GCS bucket permissions. If you see permissions missing, you can grant yourself the Storage Admin role.

It's possible you have project ownership, but not permissions on the bucket. If the bucket says that you cannot add permissions, you can still get around this by granting yourself Storage Admin at the project-level via the IAM & Admin page.

This will let you download files in Firebase Console as well as let you edit bucket permissions. And for more info on the roles and permissions, check out the docs on IAM access control.

Upvotes: 2

Related Questions