Django quickstart
Add Wocha authentication to a Django project with OIDC authentication backend for browser sessions and JWT validation for Django REST Framework API endpoints.
Add Wocha authentication to a Django project: OIDC authentication backend for browser sessions and JWT validation for Django REST Framework API endpoints.
Prerequisites
- Python 3.10+
- Django 4.2+
- Django REST Framework (for API mode)
- A Wocha project with OAuth applications (Wocha Console)
What you'll build
A Django app with browser OIDC login and optional DRF JWT validation for API endpoints.
Welcome back
After sign-in
✓ Session stored securely
✓ User profile available in your app
✓ Organisation context ready for multi-tenant features
Installation
Environment variables
Register redirect URI: http://localhost:8000/oidc/callback/
OIDC authentication backend
Add to settings.py:
Add URLs in urls.py:
Create a simple protected view in myapp/views.py:
Add routes in myapp/urls.py:
Sign-in link in a template:
JWT validation for DRF
Create myapp/authentication.py:
Configure DRF in settings.py:
Create an API view in myapp/api.py:
Register in myapp/urls.py:
Management API
Use wocha for server-side admin tasks:
Testing the integration
Browser login
-
Run migrations and start the server:
-
Visit http://localhost:8000 and click Sign in with Wocha.
-
Complete login — you should reach
/dashboard/with an authenticated session.
API mode
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