When ansible_base.oauth2_provider is used, any POST request that contains content type not supported by the rest framework will end up with HTTP 415 Unsupported Media Type.
This happens because in the oauth2_provider.contrib.rest_framework.OAuth2Authentication authentication class oauth2_provider library unconditionally makes an attempt to access requsest.POST. When DRF fails to parse incoming request body, an exception is raised, which prevents further request handling.
Normally OAuth2Authentication will only work with access token passed in request Authorization header. This patch handles this situation and prevents request processing failure when request body contains data that cannot be parsed by DRF.
When ansible_base.oauth2_provider is used, any POST request that contains content type not supported by the rest framework will end up with HTTP 415 Unsupported Media Type.
This happens because in the
oauth2_provider.contrib.rest_framework.OAuth2Authentication
authentication class oauth2_provider library unconditionally makes an attempt to accessrequsest.POST
. When DRF fails to parse incoming request body, an exception is raised, which prevents further request handling.Normally OAuth2Authentication will only work with access token passed in request
Authorization
header. This patch handles this situation and prevents request processing failure when request body contains data that cannot be parsed by DRF.