- Direct users to the Civic Auth login page
- Set up an endpoint that the auth server should redirect to once complete
- Set up middleware to ensure only logged-in users can access protected parts of your app.
Installation
Install the Civic Auth Python SDK using pip:uv package manager:
Usage
The Civic Auth Python SDK provides a flexible API that works with any Python web framework. For framework-specific integrations, see the guides above.Getting User Information on the Backend
Here are some examples of using the get_user function in popular Python server environments. Note - this snippet assumes you have followed the steps to integrate login with your app as described here.Getting the Access Token
Use CivicAuth-managed storage to retrieve tokens. Prefer the SDK helper that exposes aCivicAuth instance and call await civic.get_tokens() (auto-refreshes when needed). If your endpoint receives a bearer token from a frontend, you can also read it from the Authorization header.
Need structured validation? See the Pydantic recipe: /nexus/recipes/python-pydantic.




