Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Firebase Storage with Node.js as a Firebase user

I want to verify that Firebase Storage rules are working as expected with automated Node.js tests.

One can access Firebase Storage buckets with the Firebase Admin API or a service account, as indicated in Upload files to Firebase Storage using Node.js.

The problem is that using the Admin API or a service account circumvents the storage rules.

There is no apparent way to access Firebase Storage as a given Firebase user, as the Firebase Node.js API does not include a firebase.storage function.

In short, how can one access Firebase Storage from Node.js as a given Firebase user/uid?

like image 530
Brian M. Hunt Avatar asked Sep 20 '25 11:09

Brian M. Hunt


1 Answers

As far as I know there is currently no way to accomplish what you want.

There is a storage() service in the Firebase Admin SDK for Node.js, but as you've discovered this gives full administrative access to your bucket.

While the Admin SDK for the Realtime Database can be initialized to access the database as a specific user, this feature is not available for the Storage service.

What you want to do sounds quite reasonable though, so I recommend that you file a feature request. In the meantime, the best I can think of is running those unit tests in a browser, so that you can authenticate with the regular JavaScript client SDK.

like image 137
Frank van Puffelen Avatar answered Sep 22 '25 03:09

Frank van Puffelen