I have encountered an issue with the HTTPX Authlib Auth plugin when using the SIGNATURE_TYPE_QUERY OAuth signature type. The issue appears when the request body is non-urlencoded content, resulting in an empty request body for PUT requests.
In the auth_flow method, the body is used when returning self.prepare:
However, in the prepare method, the body is set to empty at this line:
body = b''
Here is the relevant part of the prepare method:
def prepare(self, method, uri, headers, body):
...
if CONTENT_TYPE_FORM_URLENCODED in content_type:
headers['Content-Type'] = CONTENT_TYPE_FORM_URLENCODED
uri, headers, body = self.sign(method, uri, headers, body)
elif self.force_include_body:
# To allow custom clients to work on non form encoded bodies.
uri, headers, body = self.sign(method, uri, headers, body)
else:
# Omit body data in the signing of non form-encoded requests
uri, headers, _ = self.sign(method, uri, headers, b'')
body = b''
return uri, headers, body
This leads to an empty request body for PUT requests with the SIGNATURE_TYPE_QUERY OAuth signature type and non-urlencoded content.
When making a PUT request with non-urlencoded content and using the SIGNATURE_TYPE_QUERY OAuth signature type, I expect the request body to be properly included.
Seeing the same behavior with POST requests & JSON content. removing the body = b'' line referenced above fixes the issue for me. Happy to PR if that would be helpful
Hello,
I have encountered an issue with the HTTPX Authlib Auth plugin when using the
SIGNATURE_TYPE_QUERY
OAuth signature type. The issue appears when the request body is non-urlencoded content, resulting in an empty request body for PUT requests.In the
auth_flow
method, the body is used when returningself.prepare
:However, in the
prepare
method, the body is set to empty at this line:Here is the relevant part of the
prepare
method:This leads to an empty request body for PUT requests with the SIGNATURE_TYPE_QUERY OAuth signature type and non-urlencoded content.
To Reproduce
A minimal example to reproduce the behavior:
Expected behavior
When making a PUT request with non-urlencoded content and using the SIGNATURE_TYPE_QUERY OAuth signature type, I expect the request body to be properly included.
Environment:
Additional context