DEV Community

Thai Pangsakulyanont
Thai Pangsakulyanont

Posted on

3 1

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

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)"

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay