Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to authenticate request for storage.child to download files #425

Open
nosec2 opened this issue Aug 24, 2022 · 1 comment
Open

How to authenticate request for storage.child to download files #425

nosec2 opened this issue Aug 24, 2022 · 1 comment

Comments

@nosec2
Copy link

nosec2 commented Aug 24, 2022

I am trying to use pyrebase to download a file from firebase storage. This file is located in customers/BoomMZrVfrOOOYa4JVibOJQoroT2/example.txt, I'm using this code to download it:

UID = 'BoomMZrVfrOOOYa4JVibOJQoroT2'
path_on_cloud = f"customers/{UID}/example.txt"
storage.child(path_on_cloud).download("C:\Users\username\Desktop\test\k.txt")

This works when I allow read and write to anyone from firebase storage. I'm using these firebase storage rules:

rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /customers/{userId}/{allPaths=**} {
allow read: if request.auth.uid == userId;
}
}
}

This only allows users to download files from a folder named with their user ID. The problem is that i cannot downloaded files from firebase storage if it requires authentication in my rules. If authentication is not required, then my code works.

@nosec2 nosec2 changed the title How to include UID inside of storage.child to download files How to authenticate request for storage.child to download files Aug 24, 2022
@AsifArmanRahman
Copy link

@nosec2 , Pyrebase does not support what you're looking for. However firebase-rest-api available in PyPI, which I recently started maintaining, supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants