Typing stubs for auth0-python

4.10.0.20260408 · active · verified Thu Apr 16

This is a type stub package for the `auth0-python` library, providing static type annotations that can be used by type checkers like MyPy or Pyright. It helps ensure type safety and improves IDE autocompletion for code interacting with the Auth0 Python SDK. This version of `types-auth0-python` aims to provide accurate annotations for `auth0-python==4.10.*`. It is part of the typeshed project, which releases frequently (often several times a month) to keep up with runtime library changes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `ManagementClient` from `auth0-python` (version 5.0.0+), which is fully typed by `types-auth0-python`. It fetches the domain, client ID, and client secret from environment variables and then lists all users using the `users` sub-client. The example shows how type hints from `types-auth0-python` would apply to client initialization and method calls, aiding static analysis.

import os
from auth0.management import ManagementClient
from auth0.management.users import Users
from typing import Dict, Any

# Ensure environment variables are set for actual use
AUTH0_DOMAIN: str = os.environ.get('AUTH0_DOMAIN', 'your-tenant.auth0.com')
AUTH0_CLIENT_ID: str = os.environ.get('AUTH0_CLIENT_ID', 'YOUR_CLIENT_ID')
AUTH0_CLIENT_SECRET: str = os.environ.get('AUTH0_CLIENT_SECRET', 'YOUR_CLIENT_SECRET')

# Initialize the ManagementClient with client credentials for automatic token management
# This client is fully type-hinted by types-auth0-python
management_client: ManagementClient = ManagementClient(
    domain=AUTH0_DOMAIN,
    client_id=AUTH0_CLIENT_ID,
    client_secret=AUTH0_CLIENT_SECRET
)

# Access a sub-client, e.g., for users management
users_client: Users = management_client.users

# Example: List users (response types are Pydantic models in v5, but can be dicts too)
try:
    # Use .all() for pagination convenience or .get_all() if you need more control
    all_users: list[Dict[str, Any]] = users_client.get_all()
    print(f"Found {len(all_users)} users.")
    if all_users:
        print(f"First user ID: {all_users[0].get('user_id')}")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →