#firebase #firestore #service-account #interact #user-friendly #interface #firebase-auth

fireplace

A client for Firebase that seeks to provide a user-friendly interface to interact with Firestore, Firebase Auth, and similar

3 releases (breaking)

0.3.0 Oct 18, 2024
0.2.0 Dec 6, 2023
0.1.0 Nov 27, 2023

#295 in Authentication

Download history 1/week @ 2024-07-27 9/week @ 2024-08-17 13/week @ 2024-08-24 1/week @ 2024-08-31 7/week @ 2024-09-07 26/week @ 2024-09-21 3/week @ 2024-09-28 109/week @ 2024-10-12 59/week @ 2024-10-19 3/week @ 2024-10-26 9/week @ 2024-11-02 5/week @ 2024-11-09

185 downloads per month

MIT license

200KB
4K SLoC

Fireplace

Crates.io page docs.rs docs

The bestest, best Firebase library for Rust because there are no other libraries.

This is a home-made client for Firebase's Admin SDK that seeks to provide a user friendly interface to interact with Firestore, Firebase Auth, and similar.

Dependencies

To verify ID tokens for Firebase Auth, OpenSSL is required. For installation, see the openssl crate's documentation.

Examples

Check out the examples directory or view the crate documentation on docs.rs, which includes many examples. Test-run the hello-world example with:

cargo run --example hello

This requires you to fetch your service account JSON file as described below.

Setup

The easiest way is to get your service account JSON file that can be used to authorize requests to Firebase. This file will also decide which project on Firebase to send requests to.

Your JSON file will look something like this:

{
  "type": "service_account",
  "project_id": "...",
  "private_key_id": "...",
  "private_key": "-----BEGIN PRIVATE KEY----- ...",
  "client_email": "...",
  "client_id": "...",
  "auth_uri": "...",
  "token_uri": "...",
  "auth_provider_x509_cert_url": "...",
  "client_x509_cert_url": "..."
}

Testing

Currently I've made the tests use a real in-the-cloud Firebase project to ensure that everything works as expected. However, this has the consequence that you need to set up access and be careful about tests affecting each other.

For testing, the following environment variables need to be set so the tests can connect to the cloud:

  • FIREBASE_PROJECT_ID
  • FIREBASE_CLIENT_ID
  • FIREBASE_CLIENT_EMAIL
  • FIREBASE_PRIVATE_KEY
  • FIREBASE_PRIVATE_KEY_ID

They should correspond to their values from the service account JSON file.

Additionally, some of the Firestore tests may need indices to be created. See the error messages for which.

Dependencies

~25–38MB
~581K SLoC