A python authentication library
Maintained. Last release 12 days ago, commits in 1 of the last 26 weeks. Weaker on commit activity.
pip install propelauth-pyPropelAuth 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.