How to delete file directory in pyrebase storage without usetoken

531 Views Asked by At

im making an app with firebase and using pyrebase as a wrapper. On the documentation, the delete function require userIdToken storage.delete("images/example.jpg",user["idToken"])

My app doesn't use firebase authentication so I don't know what argument to put. When I try to run the script below i get an error TypeError: delete() missing 1 required positional argument: 'token'. I just want to delete the folder. I know I can do this with the answer in this How to delete a image file from Google firebase Storage using python but I'm avoiding firebase_admin since I can't package my app on android when using that library. Im using kivy btw.

If there are any possible workaround on this without using firebase_admin, it'll be very much helpful. thank you.

firebase = pyrebase.initialize_app(config)
storage= firebase.storage()    
def delete_storage():
        storage.delete("HOKOKO")
    
    delete_storage()
1

There are 1 best solutions below

0
Coding_cole On

From here it says you can create your custom token like this

token = auth.create_custom_token("your_custom_id")

or you can create an idToken using your email and password like below

user = auth.sign_in_with_email_and_password(email, password)
before the 1 hour expiry:
user = auth.refresh(user['refreshToken'])
now we have a fresh token
user['idToken']

i also got that from here. Hope it works