Sometimes you want to upload some JSON data to Firebase Realtime Database. Usually this means generating a service account and writing a script that uses Firebase SDK to upload that data.
However, Firebase Realtime Database REST API supports Google OAuth2 access tokens.
If you installed Google Cloud SDK, such token can be generated using the following command:
gcloud auth print-access-token
The access token has access to all projects you own which makes this very convenient. That means you can now do this:
cat FILE.json | \
http put https://PROJECT.firebaseio.com/REF.json \
"Authorization: Bearer $(gcloud auth print-access-token)"
Top comments (0)