jazzband / django-oauth-toolkit

OAuth2 goodies for the Djangonauts!
https://django-oauth-toolkit.readthedocs.io
Other
3.16k stars 794 forks source link

Accepting the Raw JSON in the request body alongside of Form-data #1010

Open Alavi1412 opened 3 years ago

Alavi1412 commented 3 years ago

I'm using this package for my RESTfull API Django application. Currently, all of my requests are in RAW JSON but only endpoints that are related to Authentication (Login, Revoking Tokens, and Renewing Tokens) are in Form-data shape. This is causing an inconvenience in our front-end application.

Also, it is making the customization on Login so difficult.

Currently, for customization, I'm using such a method like this:

            request.data._mutable = True
            request.data['grant_type'] = 'password'
            request.data['username'] = request.data['username']
            request.data['client_id'] = 'laJ5q1A7sVVRiTJRwY02FzoRXn6LlyS0HtphKBcB'
            request.data['password'] = request.data['password']
            request.data['user'] = authenticate(
                username=request.data['username'], password=request.data['password']
            )

            request.data._mutable = False
           response = json.loads(TokenView().create_token_response(request)[2])

This method good be enhanced if there exists another method that accepts RAW JSON, or at least, a simple dictionary which I can customize easily.

ThomasBerne commented 2 years ago

Nothing about this in a 8 months?