#firebase #firestore #json-file #firebase-auth

fireplace

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

2 unstable releases

0.2.0 Dec 6, 2023
0.1.0 Nov 27, 2023

#331 in Authentication

Download history 24/week @ 2024-01-07 23/week @ 2024-02-11 29/week @ 2024-02-18 45/week @ 2024-02-25 20/week @ 2024-03-03 20/week @ 2024-03-10 6/week @ 2024-03-17 69/week @ 2024-03-31 7/week @ 2024-04-07 30/week @ 2024-04-14

106 downloads per month

MIT license

195KB
3.5K 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

~24–38MB
~606K SLoC