thisbejim / Pyrebase

A simple python wrapper for the Firebase API.
2.05k stars 525 forks source link

Fixed get_url to return valid download link for service accounts. For multiple issues regarding 403 error. #404

Closed kinguardo closed 9 months ago

kinguardo commented 2 years ago

In case a service account was provided, call generate_signed_url endpoint instead of the default logic, to get a valid PUBLIC download link. By default, set the link expiration to 12 hours. For custom value, optional expiration parameter can be provided.

Fix for these issues regarding 403 error if service account being used was the cause of the issue: 218, 142, 100

Sample code used for testing:

import pyrebase

config = {} # set all the keys including "serviceAccount"

firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
file = storage.child("cat.jpg") # set the correct path
print(file.get_url())

Output: check

AsifArmanRahman commented 1 year ago

Hi there, I've initiated a project to maintain this library, and I'll be using your solution to fix the mentioned bug. I'll co-author you in the commit of the fix, as I've modified it a bit. Feel free to reach me using my email displayed in my profile.

Repo: firebase-rest-api available in PyPI

best regards