skip to Main Content

We have already used firebase storage for storing the images and files in our application. Recently our files seem to bee not loading in the application and once cross-checking I found the following error.

{
  "error": {
    "code": 412,
    "message": "A required service account is missing necessary permissions. Please resolve by visiting the Storage page of the Firebase Console and re-linking your Firebase bucket or see this FAQ for more info: https://firebase.google.com/support/faq#storage-accounts"
  }
}

After further investigation, I found a solution in the below-related FAQ.
https://firebase.google.com/support/faq/index#storage-accounts

As per the documentation, I have created a new service account with the I am admin role as Cloud Storage for Firebase Service Agent. It created a service account called service account name service-PROJECT_NUMBER@PROJECT_id.iam.gserviceaccount.com. Also, I have enabled the IAM admin policies for managing services. But still but storage URL is not loading.

Do I need to add any more changes to storage permissions? How can I use the existing storage bucket data with the new updates?

4

Answers


  1. Chosen as BEST ANSWER

    I fixed the issue with the following steps. After setting the IAM policies in storage admin I tried with AddFirebaseAPI function using postman by passing the project id and storage bucket name. But it returns a not found error for me. I tried it with both project number as well as id. Both given the same error. About the error using Postman and the URL this should be working it solved by using

    https://firebasestorage.googleapis.com/v1beta/projects/<projectid>/buckets/<bucketname>:addFirebase
    

    Here is an example of the HTTP call that the playground gives you

    POST 
    https://firebasestorage.googleapis.com/v1beta/projects/<projectid>/buckets/<bucketname>:addFirebase?key=[YOUR_API_KEY] HTTP/1.1
    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    Content-Type: application/json
    

    It will returns your bucket instance. Also it may takes a few mins to reflect the changes.


  2. I just fixed this for my self.

    1. Create a bucket in Cloud Storage
    2. Get your projectname and bucket name
    3. Go here: https://firebase.google.com/docs/reference/rest/storage/rest/v1beta/projects.buckets/addFirebase
    4. Press Try IT
    5. Fill in your projectname en bucket name. Press Execute é voila!

    See my screenshot here

    Login or Signup to reply.
  3. As mentioned in this github.

    On the IAM page with the project owner role you will have an option to Grant Access.
    add this service account.
    service-project [email protected] as a principle, Cloud Storage for Firebase Service Agent as role.

    If you are having trouble adding the service account ([email protected]) to the project, it’s possible that Cloud Storage for Firebase has not created it yet.

    Try using the AddFirebase API to relink a bucket to your project and try again: You can refer to this

    Login or Signup to reply.
  4. If you open firebase-storage in console.firebase.google.com,
    it gives you an alert saying attach permission. If you click on it, problem should be fixed automatically.

    If it doesn’t solve, then follow this Github

    If you don’t find project number @gcp-sa-firebasestorage.iam.gserviceaccount.com in console permission, then make sure you click on attach permission dialog in firebase storage.

    This is how my problem was solved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search