Usage

Command Line Interface (CLI)

Start an API server (go to http://localhost:8000/docs to try the API):

>>> msdss-users start

Register a user:

>>> msdss-users register

Get user info:

>>> msdss-users get <email>

Update a user’s attributes:

>>> msdss-users update <email> --is_superuser True

Reset password for a user:

>>> msdss-users reset <email>

Delete a user:

>>> msdss-users delete <email>

Warning

Do not forget to setup your environment variables (see Quick Start)

Note

For more information, you can get help for each command:

>>> msdss-users --help
>>> msdss-users start --help
>>> msdss-users register --help
>>> msdss-users get --help
>>> msdss-users update --help
>>> msdss-users reset --help
>>> msdss-users delete --help

Python

In Python, use the package via msdss_users_api.core.UsersAPI:

from fastapi import Depends
from msdss_users_api import UsersAPI
from msdss_users_api.models import User

# Create app using env vars
app = UsersAPI()

# Get a function dependency for the current active user
current_active_user = app.get_current_user(active=True)

# Add a protected route
@app.route('GET', '/protected-route')
def protected_route(user: User = Depends(current_active_user)):
    return f'Hello, {user.email}'

# Run the app with app.start()
# API is hosted at http://localhost:8000
# Try API at http://localhost:8000/docs
# app.start()

Warning

Do not forget to setup your environment variables (see Quick Start)