Installation
pip install async-firebase-rest-api
Quick Start
In order to use this library, you first need to go through the following steps:
-
Select or create a Firebase project from Firebase Console.
-
Register an Web App.
Example Usage
import firebase
config = {
"apiKey": "apiKey",
"authDomain": "projectId.firebaseapp.com",
"databaseURL": "https://databaseName.firebaseio.com",
"projectId": "projectId",
"storageBucket": "projectId.appspot.com",
"messagingSenderId": "messagingSenderId",
"appId": "appId"
}
app = firebase.initialize_app(config)
auth = app.auth()
await auth.create_user_with_email_and_password(email, password)
user = await auth.sign_in_with_email_and_password(email, password)
db = app.database()
data = {
"name": "Robert Downey Jr.",
"email": await user.get('email')
}
await db.child("users").push(data, user.get('idToken'))
storage = app.storage()
file_path = 'static/img/example.png'
await storage.child(user.get('localId')).child('uploaded-picture.png').put(file_path, user.get('idToken'))