Pyrebase4

raw JSON →
4.9.0 verified Fri May 01 auth: no python

A Python wrapper for the Firebase API with updated dependencies, version 4.9.0. Active development with frequent releases.

pip install pyrebase4
error ModuleNotFoundError: No module named 'oauth2client'
cause Missing oauth2client dependency (installed automatically with pyrebase4, but may be missing in some environments).
fix
pip install oauth2client
error TypeError: __init__() got an unexpected keyword argument 'max_retries'
cause Incompatible version of requests (<2.31.0) with pyrebase4 >=4.8.0.
fix
pip install --upgrade requests>=2.31.0
error AttributeError: 'NoneType' object has no attribute 'key'
cause Occurs when using outdated Pyrebase code with newer requests that changed response structure (common after v4.8.0).
fix
Upgrade pyrebase4 to latest (v4.9.0) and ensure requests >=2.31.0.
error google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.
cause Trying to use Firebase Admin SDK features without proper credentials (Pyrebase4 uses Firebase Auth, not Admin SDK).
fix
Use Firebase Auth REST API via pyrebase4 auth methods instead of Admin SDK. If you need Admin SDK, use firebase-admin instead.
breaking Versions >=4.8.0 require requests >=2.31.0, which has API changes. Older requests versions will break.
fix Run pip install --upgrade requests>=2.31.0
breaking v4.6.0 changed get_etag() return format: now returns an object with 'ETag' and 'value' keys, not just the ETag string. conditional_set and conditional_remove expect the new format.
fix Update code to handle the new object: etag_result = db.child('path').get_etag(); etag_value = etag_result['ETag']
breaking v4.9.0 dropped support for App Engine (Google App Engine runtime). If you deploy on App Engine, you must pin to v4.8.0 or earlier.
fix Either migrate away from App Engine or use pyrebase4==4.8.0
gotcha Firebase Auth with email/password may fail if 'Email Enumeration Protection' is enabled in Firebase project settings. The library does not handle this gracefully.
fix Disable email enumeration protection in Firebase console, or handle exceptions with appropriate user feedback.
deprecated The library uses oauth2client, which is deprecated and may have security issues. Future versions may migrate to google-auth.
fix Monitor for updates; consider pinning to a version that still works if migration breaks your code.

Initialize Pyrebase with Firebase config and authenticate a user.

import pyrebase

config = {
    "apiKey": os.environ.get('FIREBASE_API_KEY', ''),
    "authDomain": os.environ.get('FIREBASE_AUTH_DOMAIN', ''),
    "databaseURL": os.environ.get('FIREBASE_DATABASE_URL', ''),
    "storageBucket": os.environ.get('FIREBASE_STORAGE_BUCKET', '')
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
user = auth.sign_in_with_email_and_password("test@example.com", "password")
print(user)