I have a python application which requires me to dump a few files into a Firebase Storage bucket, update an HTML file's img links so they point to the previously uploaded files + Token, and then save off the HTML file itself into the bucket for later use. The problem I'm having is that I can't seem to find a way in Python to fetch the unique token of the blob/file. For reference, I have been accomplishing this in Javascript using getDownloadURL which provides me with a URL that looks like this: https://firebasestorage.googleapis.com/v0/b/[project].appspot.com/o/[bucket]%2Ffile.png?alt=media&token=[token]
When I use the google-cloud-python blob method 'path' it gives me a URL without the token, which I can already construct on my own: /b/[project].appspot.com/o/[bucket]%2Ffile.png
Can anybody please help point me in the direction of what method I can use to retrieve the blob/file's token so I can construct the full URL?
from firebase_admin import credentials
from firebase_admin import storage
try:
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://[project].firebaseio.com'
})
except Exception as e:
print str(e.message)
bucket = storage.bucket('[project].appspot.com')
blob1 = bucket.blob(userId + '/' + file)
with open(os.path.join(tmp_dir, file), 'rb') as my_file:
blob1.upload_from_file(my_file)
#Now I need the token but this only prints the path I already know
print blob1.path