OAuth2 goodies for the Djangonauts!
Django OAuth Toolkit is an OAuth 2.0 authorization server for teams already running Django. It provides, out of the box, the endpoints, models, and logic to issue and manage OAuth2 tokens from your existing Django project, instead of standing up and operating a separate service.
As of 3.4.0, Django OAuth Toolkit supports the authorization server role required by the
Model Context Protocol (MCP) authorization specification: PKCE is required by default, and the
authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728) discovery
endpoints are included in the default URLconf. Dynamic Client Registration (RFC 7591/7592) and
Client ID Metadata Documents can be enabled with the DCR_ENABLED and CIMD_ENABLED settings.
See the
3.4.0 release discussion
for the supported specifications and current gaps.
Django OAuth Toolkit can also act as a resource server to protect a Django or Django REST Framework API with OAuth2. It makes extensive use of the excellent OAuthLib, so that everything is rfc-compliant.
Please report any security issues to the Django OAuth security team at <django-oauth-security@googlegroups.com>. Do not file an issue on the tracker.
- Python 3.10, 3.11, 3.12, 3.13 or 3.14
- Django 4.2, 5.0, 5.1, 5.2 or 6.0
- oauthlib 3.2.2+
Install with pip:
pip install django-oauth-toolkit
Add oauth2_provider to your INSTALLED_APPS
INSTALLED_APPS = (
...
'oauth2_provider',
)If you need an OAuth 2.0 authorization server you'll want to add the following to your urls.py.
from oauth2_provider import urls as oauth2_urls
urlpatterns = [
...
path('o/', include(oauth2_urls)),
]See CHANGELOG.md.
The full documentation is on Read the Docs.
django-oauth-toolkit is released under the terms of the BSD license. Full details in LICENSE file.
We need help maintaining and enhancing django-oauth-toolkit (DOT).
There are no barriers to participation. Anyone can open an issue, pr, or review a pull request. Please dive in!
See our contributing info and the open issues and PRs, especially those labeled help-wanted.
Have questions or want to discuss the project? See the discussions.
PR submissions and reviews are always appreciated! Since we require an independent review of any PR before it can be merged, having your second set of eyes looking at PRs is extremely valuable.
If you are interested in stepping up to be a Maintainer, please open an issue. For maintainers we're looking for a positive attitude, attentiveness to the specifications, strong coding and communication skills, and a willingness to work with others. Maintainers are responsible for merging pull requests, managing issues, creating releases, and ensuring the overall health of the project.