Django OAuth Toolkit


1. Simple OAuth 2.0 Server

from django_oauth_toolkit.decorators import oauth2_required
from django_oauth_toolkit.models import Grant
from django.utils.decorators import method_decorator

class ProtectedView(View):
    @method_decorator(oauth2_required(scopes=["read:profile"]))
    def get(self, request, *args, **kwargs):
        # Access to the protected data
        grants = Grant.objects.all()
        return render(request, "protected.html", {"grants": grants})

2. Authorize Endpoint

from django_oauth_toolkit.views import AuthorizeEndpointView

class CustomAuthorizeEndpointView(AuthorizeEndpointView):
    # Customization of the authorize endpoint
    def get_authorization_request(self, request, client_id):
        # Here you could validate the request or perform any additional checks
        return super().get_authorization_request(request, client_id)

3. Django Admin Integration

4. Token Endpoint

5. Introspection Endpoint

6. Revoke Endpoint

7. OAuth 2.0 Client Registration

8. Token Resource Server

9. JWT Token Generation

10. Client Credentials Grant

11. User Authorization Code Grant

12. Refresh Token Grant

13. Password Credentials Grant

14. JWT Claims Customizer

15. Remote User Authentication

16. Social Authentication

17. Aggregate Authentication