FastAPI quickstart
Add Wocha authentication to a Python FastAPI service with JWT access token validation on protected endpoints and the wocha Management SDK for admin operations.
Add Wocha authentication to a Python FastAPI service: validate JWT access tokens on protected endpoints and use the wocha Management SDK for admin operations.
Prerequisites
- Python 3.10+
- A Wocha project with an OAuth application (Wocha Console)
What you'll build
A FastAPI service with JWT-protected routes and Management API integration.
Welcome back
After sign-in
✓ Session stored securely
✓ User profile available in your app
✓ Organisation context ready for multi-tenant features
Installation
Environment variables
Create a .env file:
JWT validation dependency
Create app/auth.py:
Protected endpoint
Create app/main.py:
Run the server:
Testing the integration
-
Start the API (command above).
-
Obtain an access token from your frontend or the hosted login flow.
-
Call the protected endpoint:
-
Open the interactive docs at http://localhost:8000/docs, click Authorize, and paste a bearer token to test endpoints in the browser.
Next steps
- SDK reference — hooks, server helpers, and configuration options
- Webhooks overview — receive user and session lifecycle events
- Common patterns — protect routes, org switching, and role-based UI