Installation
pip install 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()
auth.create_user_with_email_and_password(email, password)
user = auth.sign_in_with_email_and_password(email, password)
db = app.database()
data = {
"name": "Robert Downey Jr.",
"email": user.get('email')
}
db.child("users").push(data, user.get('idToken'))
storage = app.storage()
file_path = 'static/img/example.png'
storage.child(user.get('localId')).child('uploaded-picture.png').put(file_path, user.get('idToken'))