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"
}
)
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 Corpclaim_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fauthy_python_sdk-0.2.2.tar.gz.
File metadata
- Download URL: fauthy_python_sdk-0.2.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0124ca00a2486f9824a10b20cc0d2f5e4e3fa6bff589dd7aab8e7d06035f9a3
|
|
| MD5 |
cbe6368f41b008fd171647023ea3756e
|
|
| BLAKE2b-256 |
cb46d4512b34bb579206644ff74552903dd13f8f7f254942ce6c02967872545c
|
Provenance
The following attestation bundles were made for fauthy_python_sdk-0.2.2.tar.gz:
Publisher:
python-publish.yml on Studio-Piot/fauthy-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fauthy_python_sdk-0.2.2.tar.gz -
Subject digest:
a0124ca00a2486f9824a10b20cc0d2f5e4e3fa6bff589dd7aab8e7d06035f9a3 - Sigstore transparency entry: 500139959
- Sigstore integration time:
-
Permalink:
Studio-Piot/fauthy-python-sdk@da32590e9967cf73c4bbccda9d0a71ad281be4dd -
Branch / Tag:
refs/tags/0.2.2 - Owner: https://github.com/Studio-Piot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@da32590e9967cf73c4bbccda9d0a71ad281be4dd -
Trigger Event:
release
-
Statement type:
File details
Details for the file fauthy_python_sdk-0.2.2-py3-none-any.whl.
File metadata
- Download URL: fauthy_python_sdk-0.2.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
279e542611261a689dc1e8b9aafd6ec210d662cba1e5ea520049f0ebcfef2802
|
|
| MD5 |
13383664bf123b0830d54dc0531394a5
|
|
| BLAKE2b-256 |
e0e3eac9e1f4e15b7e339f5041dff6ad70337e8bafdcbb7dfceaa2ec863efba7
|
Provenance
The following attestation bundles were made for fauthy_python_sdk-0.2.2-py3-none-any.whl:
Publisher:
python-publish.yml on Studio-Piot/fauthy-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fauthy_python_sdk-0.2.2-py3-none-any.whl -
Subject digest:
279e542611261a689dc1e8b9aafd6ec210d662cba1e5ea520049f0ebcfef2802 - Sigstore transparency entry: 500139985
- Sigstore integration time:
-
Permalink:
Studio-Piot/fauthy-python-sdk@da32590e9967cf73c4bbccda9d0a71ad281be4dd -
Branch / Tag:
refs/tags/0.2.2 - Owner: https://github.com/Studio-Piot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@da32590e9967cf73c4bbccda9d0a71ad281be4dd -
Trigger Event:
release
-
Statement type: