You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the DRF and creating an action view to upload a raw file in a POST body, the OAuth2 authenticator messes up this request raising either rest_framework.exceptions.UnsupportedMediaType, or django.core.exceptions.TooManyFieldsSent.
It happens because of the unconditional call of the request.POST.items() in the OAuthLibCore.extract_body() method.
To Reproduce
Create some raw upload URL using the DRF. My code was approximately:
Describe the bug
When using the DRF and creating an action view to upload a raw file in a POST body, the OAuth2 authenticator messes up this request raising either
rest_framework.exceptions.UnsupportedMediaType
, ordjango.core.exceptions.TooManyFieldsSent
.It happens because of the unconditional call of the
request.POST.items()
in theOAuthLibCore.extract_body()
method.To Reproduce
Create some raw upload URL using the DRF. My code was approximately:
Register this view in the DRF as usual
Setup the OAuth2 DRF authorization provided by the toolkit:
Start the server.
Authorize yourself somehow (using OAuth2, f.e.)
Try to upload some binary file:
The result is failed, with a response code=415 like
Try to upload a big binary file ignoring a
Content Type
header:curl http://127.0.0.1:8000/api/base_maps/some_id/upload/ --data-binary @some-file-for-upload.bin -H "Authorization: ...."
The result is failed, with a response 400 Bad Request (the
django.core.exceptions.TooManyFieldsSent
is reported in the console).Expected behavior
Success processing and response as minimum in the first case.
Version
django-oauth-toolkit==2.3.0
Additional context
The change like the following fixes the issue:
The text was updated successfully, but these errors were encountered: