DEV Community


Import/export data into/from Firebase Realtime Database from your terminal using HTTPie and Google Cloud SDK

dtinth profile image Thai Pangsakulyanont ・1 min read

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 \
    "Authorization: Bearer $(gcloud auth print-access-token)"

Discussion (0)

Editor guide