Skip to main content

SDK to consume Fauthy API from a FastAPI application.

Project description

Fauthy Python SDK

A Python SDK for interacting with the Fauthy API.

Installation

pip install fauthy-python-sdk

Usage

Basic Setup

from fauthy_sdk import FauthyClient

# Initialize the client
client = FauthyClient(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

Management API

The SDK provides access to the Fauthy Management API v1 endpoints.

Get Management Info

response = client.get_management_info()
print(response.json())

List Users

# Basic listing
response = client.list_users()

# With pagination and search
response = client.list_users(
    page=1,
    query="john",
    per_page=20
)

# With custom claims filtering
custom_claims = {
    "company": "Test Corp",
    "department": "Engineering"
}
response = client.list_users(
    page=1,
    query="",
    per_page=10,
    custom_claims_filter=custom_claims
)

Create User

response = client.create_user(
    email="user@example.com",
    first_name="John",
    last_name="Doe",
    roles=["role_uuid_1", "role_uuid_2"],
    custom_claims={
        "company": "Test Corp",
        "department": "Engineering"
    },
    mark_as_verified=True
)

Get User

response = client.get_user("user_uuid")

Update User

response = client.update_user(
    user_id="user_uuid",
    first_name="Jane",
    last_name="Smith",
    email="jane@example.com"
)

Delete User

response = client.delete_user("user_uuid")

Set User Password

response = client.set_user_password(
    user_id="user_uuid",
    password="new_secure_password"
)

List Roles

# Basic listing
response = client.list_roles()

# With pagination
response = client.list_roles(
    page=1,
    n_per_page=50
)

Custom Claims Filtering

The SDK supports filtering users by custom claims using the custom_claims_filter parameter in the list_users method. This allows you to filter users based on their custom JWT claims.

Example

# Filter users by company and department
custom_claims = {
    "company": "Test Corp",
    "department": "Engineering"
}

response = client.list_users(
    page=1,
    per_page=20,
    custom_claims_filter=custom_claims
)

This will send a request with query parameters like:

  • claim_company=Test Corp
  • claim_department=Engineering

The API will return only users whose custom claims match these values.

Error Handling

The SDK raises requests.exceptions.RequestException for HTTP errors. You can handle these exceptions to manage API errors:

import requests

try:
    response = client.get_user("user_uuid")
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"API Error: {e}")

Response Format

All methods return a requests.Response object. You can access the JSON data using:

response = client.list_users()
data = response.json()
print(f"Total users: {data['total']}")
print(f"Users: {data['items']}")

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

fauthy_python_sdk-0.2.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

fauthy_python_sdk-0.2.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file fauthy_python_sdk-0.2.4.tar.gz.

File metadata

  • Download URL: fauthy_python_sdk-0.2.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fauthy_python_sdk-0.2.4.tar.gz
Algorithm Hash digest
SHA256 211e500a79c2a2d6e971c728714febe5b98eab6b251337f5595371a8f30ab54b
MD5 54f9d21d6902c39d3866315180e9ebc0
BLAKE2b-256 02f35460438b0f47d3f903ff48a5f6bc1fbe55e25d7e95a00526f71787ec04b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for fauthy_python_sdk-0.2.4.tar.gz:

Publisher: python-publish.yml on Studio-Piot/fauthy-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fauthy_python_sdk-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fauthy_python_sdk-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f20a857f3fded5f1b9e620555dcab7d339098a57b3f8734fa34d2a43066c489
MD5 deab7b91dc093a91ff4bb54030a9466d
BLAKE2b-256 3949b2764b7ee2dc75dc79b4873594900cf776e54d98a05c371178104908b533

See more details on using hashes here.

Provenance

The following attestation bundles were made for fauthy_python_sdk-0.2.4-py3-none-any.whl:

Publisher: python-publish.yml on Studio-Piot/fauthy-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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