pyauth / requests-http-signature

A Requests auth module for the IETF HTTP Message Signatures draft standard

Home Page:https://pyauth.github.io/requests-http-signature/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support httpx

max-tet opened this issue · comments

HTTPX tries to be compatible with the requests package, including the use of callables for custom authentication. However, it is incompatible with requests_http_signature. When trying to sign a request, this is the error: AttributeError: 'Request' object has no attribute 'body'

requests_http_signature expects the body attribute here, but the Request object does not have the attribute because it is called content.

What I don't understand is that the Request object of the Requests library also seems to have no attribute called body. Why does it work here then?

Thanks, I'll take a look at making this package compatible with httpx. The first step would be to write a test case.

The reason you're not seeing body is that it's an attribute of PreparedRequest, not Request. The auth helper plugin operates on PreparedRequest.

Right, thanks for the clarification. AFAIK, httpx has no notion of a prepared request. But I guess that should not be a problem.

It looks like the httpx auth protocol is substantially different and will require a new package. Supporting httpx is outside the scope of this package, but can be accommodated by a new package in the pyauth project.

https://github.com/encode/httpx/blob/master/httpx/_auth.py

Thanks for looking into that. So httpx and Requests are not as compatible as advertised. I'll get back to using Requests then for the moment.