Fireplace
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.
Documentation
Complete API documentation with examples is available on docs.rs.
Key documentation pages:
- Crate overview - Getting started guide with examples for both Firestore and Firebase Auth
- Firestore module - Firestore usage guide including queries, filters, and pagination
- FirestoreClient - Complete Firestore API reference
- Firebase Auth module - User management and authentication guide
- FirebaseAuthClient - Complete Auth API reference
Examples
Check out the examples directory, which includes working code samples. 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:
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_IDFIREBASE_CLIENT_IDFIREBASE_CLIENT_EMAILFIREBASE_PRIVATE_KEYFIREBASE_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.