0

I am trying to upload a picture to my firebase storage account, but whenever I run the code, I am having a 403 HTTP error: "The project to be billed is associated with an absent billing account". Note that I am using the free subscription (spark plan), so this question is not similar to: Google Cloud Storage bucket throws error "The project to be billed is associated with a closed billing account."

A more verbose error:

"error": {
    "code": 403,
    "message": "The project to be billed is associated with an absent billing account.",
    "errors": [
      {
        "message": "The project to be billed is associated with an absent billing account.",
        "domain": "global",
        "reason": "accountDisabled",
        "locationType": "header",
        "location": "Authorization"
      }
    ]
  }

Here is my code in Python:

import firebase_admin
from firebase_admin import credentials, storage
import os


cred = credentials.Certificate(os.getenv("FIREBASE_CREDS"))
firebase_admin.initialize_app(cred)
bucket = storage.bucket('profile_pictures')
blob = bucket.blob("test_image.jpg")
blob.upload_from_string(test_image_path)

Is the problem coming from my python code, or from some settings I need to fix in firebase? With the Spark plan, we are supposed to have some free storage (and for now, I didn't store anything ...)

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
  • 1
    Are you sure that `profile_pictures` is a bucket name and not a "folder" name (you can see folders in the Firebase console but they are not real folders, just generated from a slash separated file name)? Can you show a picture of your Firebase Cloud Storage console? – Renaud Tarnec Aug 27 '20 at 13:25
  • it's definitely a folder name! I don't see any other values I could give ? –  Aug 27 '20 at 13:30
  • Ok that was the issue ... in bucket, I should have give my appspot url. And then in bucket.blob: "folder_name/picture_name". If I may, I think the HTTP error message is misleading !! But thanks a lot !! –  Aug 27 '20 at 13:33

1 Answers1

0

The problem comes from the fact that you mix up "bucket" and "filename".

You need to pass the following value to the storage.bucket() method: gs://[your-project-id].appspot.com

and

you need to pass the full file name to bucket.blob(), including the "folder" part.


Note that you can see folders in the Firebase console but, actually, they are not real folders: They are just generated from slash separated file names, in order to ease the navigation in the Firebase console.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121