Skip to main content

A user management package using Firebase

Project description

User Management

A Python package for managing user-related operations using Firebase Authentication.

Installation

You can install the package using pip:

pip install user-management

Prerequisites

  1. A Firebase project
  2. Firebase service account credentials (as a JSON file or dictionary)
    • Go to Firebase Console
    • Project Settings > Service Accounts
    • Generate New Private Key

Usage

from user_management import FirebaseClient, FirebaseUser

# Initialize the client with your service account credentials
# Method 1: Using a credentials file path (recommended)
client = FirebaseClient("path/to/firebase-credentials.json")

# Method 2: Using a credentials dictionary
client = FirebaseClient({
    "type": "service_account",
    "project_id": "your-project-id",
    "private_key_id": "key-id",
    "private_key": "-----BEGIN PRIVATE KEY-----\n...",
    "client_email": "firebase-adminsdk...iam.gserviceaccount.com",
    "client_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/..."
})

# Create a new user
user = client.create_user(
    email="user@example.com",
    password="securepassword123",
    display_name="John Doe"
)
print(f"Created user: {user.uid}")

# Get user information
user = client.get_user(uid="user123")
print(f"User email: {user.email}")

# Update user
updated_user = client.update_user(
    uid="user123",
    display_name="John Smith",
    email="new.email@example.com"
)

# Set custom claims (e.g., for role-based access)
client.set_custom_claims("user123", {"admin": True})

# Verify a Firebase ID token
token_claims = client.verify_token("firebase-id-token")
print(f"User ID: {token_claims['uid']}")

# Delete a user
client.delete_user("user123")

Features

  • User creation and management
  • User information retrieval and updates
  • Custom claims management
  • JWT token verification
  • Type-safe with Pydantic models
  • Full Firebase Authentication integration
  • Flexible initialization with file path or credentials dictionary
  • Strong type hints and documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

user_management-0.4.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

user_management-0.4.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file user_management-0.4.0.tar.gz.

File metadata

  • Download URL: user_management-0.4.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for user_management-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e83a4e69edddd62f2b78d1849c4596beec9f585007e0391c060608f42f2753de
MD5 d54d40f154fbf09bea21bfe6551f68b0
BLAKE2b-256 b551628e934f8b4ade54db6233c8cee2bc61b3206160b94f4c7ad5a0070b3f04

See more details on using hashes here.

File details

Details for the file user_management-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for user_management-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fa49fe111e7fab0330c7e135e3137ae5eabeeedc46a51bc587a071a38459b57
MD5 89f08dc0c85f0988f1224d0be8e9507e
BLAKE2b-256 90f9d18dfcebefcc5d7842dfb5499f4d9443a3066b50a65be5a492a472e4da2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page