PropelAuth Python SDK
A python library for managing authentication, backed by PropelAuth.
PropelAuth makes it easy to add authentication and authorization to your B2B/multi-tenant application.
Your frontend gets a beautiful, safe, and customizable login screen. Your backend gets easy authorization with just a few lines of code. You get an easy-to-use dashboard to config and manage everything.
Documentation
Installation
pip install propelauth_py
Initialize
init_base_auth performs a one-time initialization of the library.
It will verify your api_key is correct and fetch the metadata needed to verify access tokens with validate_access_token_and_get_user.
from propelauth_py import init_base_auth
auth = init_base_auth("YOUR_AUTH_URL", "YOUR_API_KEY")
Protect API Routes
After initializing auth, you can verify access tokens by passing in the Authorization header (formatted Bearer TOKEN) to validate_access_token_and_get_user.
You can see more information about the User object returned in User.
auth_header = # get authorization header in the form `Bearer {TOKEN}`
try:
user = auth.validate_access_token_and_get_user(auth_header)
print("Logged in as", user.user_id)
except UnauthorizedException:
print("Invalid access token")
Authorization / Organizations
You can also verify which organizations the user is in, and which roles and permissions they have in each organization all through the User object.
Check Org Membership
Verify that the request was made by a valid user and that the user is a member of the specified organization. This can be done using the User object.
auth_header = # get authorization header in the form `Bearer {TOKEN}`
org_id = # get org id from request
try:
user = auth.validate_access_token_and_get_user(auth_header)
org = user.get_org(org_id)
if org is None:
# return 403 error
print(f"You are in org {org.org_id}")
except UnauthorizedException:
print("Invalid access token")
Check Org Membership and Role
Similar to checking org membership, but will also verify that the user has a specific Role in the organization. This can be done using either the User or OrgMemberInfo objects.
A user has a Role within an organization. By default, the available roles are Owner, Admin, or Member, but these can be configured. These roles are also hierarchical, so Owner > Admin > Member.
## Assuming a Role structure of Owner => Admin => Member
auth_header = # get authorization header in the form `Bearer {TOKEN}`
org_id = # get org id from request
try:
user = auth.validate_access_token_and_get_user(auth_header)
org = user.get_org(org_id)
if (org is None) or (org.user_is_role("Owner") == False):
# return 403 error
print(f"You are an Owner in org {org.org_id}")
except UnauthorizedException:
print("Invalid access token")
Check Org Membership and Permission
Similar to checking org membership, but will also verify that the user has the specified permission in the organization. This can be done using either the User or OrgMemberInfo objects.
Permissions are arbitrary strings associated with a role. For example, can_view_billing, ProductA::CanCreate, and ReadOnly are all valid permissions.
You can create these permissions in the PropelAuth dashboard.
auth_header = # get authorization header in the form `Bearer {TOKEN}`
org_id = # get org id from request
try:
user = auth.validate_access_token_and_get_user(auth_header)
org = user.get_org(org_id)
if (org is None) or (org.user_has_permission("can_view_billing") == False):
# return 403 error
print(f"You can view billing information for org {org.org_id}")
except UnauthorizedException:
print("Invalid access token")
Calling Backend APIs
You can also use the library to call the PropelAuth APIs directly, allowing you to fetch users, create orgs, and a lot more. See the API Reference for more information.
from propelauth_py import init_base_auth
auth = init_base_auth("YOUR_AUTH_URL", "YOUR_API_KEY")
magic_link = auth.create_magic_link(email="test@example.com")
Logging Configuration
You can configure the logging behavior of the PropelAuth library to control whether exceptions are logged:
# When initializing the library:
auth = init_base_auth("YOUR_AUTH_URL", "YOUR_API_KEY", log_exceptions=False)
# Or after initialization:
auth.configure_logging(log_exceptions=False)
# Or without an Auth instance:
from propelauth_py import configure_logging
configure_logging(log_exceptions=False)
By default, exceptions are logged using Python's standard logging module. Setting log_exceptions=False will disable this behavior.
Questions?
Feel free to reach out at support@propelauth.com
Release files for propelauth-py 4.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| propelauth_py-4.4.0.tar.gz | 79.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| propelauth_py-4.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 129.8 kB
Release files / propelauth_py-4.4.0.tar.gz
| Download URL | propelauth_py-4.4.0.tar.gz |
|---|---|
| Size | 79.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0767ff4765db9eeb71a4097f3e92a890e6cd53422fcfa813e0ed03a8e048b5b4
|
|
BLAKE2b-256 checksum How to use checksums |
3490d60021e27dc545624a5bd9b1e251f698d422e802b7ed7a5ff87e21cfa571
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency logRelease files / propelauth_py-4.4.0-py3-none-any.whl
| Download URL | propelauth_py-4.4.0-py3-none-any.whl |
|---|---|
| Size | 50.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
becad678dc9b42a3df3332dec692de93723ec9076fd8fffac2a0265b51577bae
|
|
BLAKE2b-256 checksum How to use checksums |
e710b330df852fc6776bb701218ed416a4a8aebf4308c521060568746d5ca018
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency log