How to get Firebase Storage token using pyrebase?

43 Views Asked by At

I am trying to find a way to grab the token that is used when I upload an image to Firebase storage using pyrebase. Right now I can get the full path URL to return, but it always leaves out the token, and I was wondering if anyone could help me out?

config = {
       "apiKey": "myKey",
        "authDomain": "https://example.com",
        "databaseURL": "https://database.com",
        "storageBucket": "storage.com",
         "serviceAccount": "file.json"
}
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
storage_location = '/post-images/img.jpg'
local_image_path = full_path_random_image
try:
    storage.child(storage_location).put(local_image_path)
    print(f"Image uploaded to Firebase Storage at: {storage_location}")
    download_url = storage.child(storage_location).get_url(None)
    print(download_url)

The code works and will upload the image perfectly but as I stated when I go to download the image URL I get the whole URL, but it is missing the token.

What I get: https://firebasestorage.googleapis.com/v0/b/myspot.com/o/post-images%2Fimg.jpg?alt=media

What I want: https://firebasestorage.googleapis.com/v0/b/myspot.com/o/post-images%2Fimg.jpg?alt=media&token=ASDkjabduiqjkbasd

0

There are 0 best solutions below