-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prepared URL API #2516
Comments
We have no such functionality yet but not maybe we need to invite something. |
Isn't yarl about this? IIRC, it's possible to pass yarl.URL instance as url to request object. |
Yes, sure. |
The use-case I'd use this for HMAC signing the HTTP request for API authentication purposes. Some APIs require that you provide an HMAC signature that's based on a combination of body, URL and headers. The signature is then added to the request (as a another header, URL parameter or extra element in the post body). See https://stackoverflow.com/questions/42100488/how-do-i-sign-a-post-request-using-hmac-sha512-and-the-python-requests-library for an example of HMAC request signing based on the post body, with the signature placed in the header. |
@asvetlov I thought I'd take a look at this, but I realised it isn't as easy a fix as I'd hoped. Have I missunderstood the problem? If so, where would you be able to implement this functionality? If not, is there any intention of adding a prepared request feature such as requests PreparedRequests? |
I feel like there's maybe something you could already do with a custom request class, like maybe:
This might also have the advantage of making the auth process automatic and encapsulated in this class, avoiding any need to change the way requests are made. Otherwise, maybe you can move the code which creates this to another location in the client so it can be retrieved more easily: |
Is there a way to get prepared URL, which will be used in a query? Something like:
I need this for authentication purposes.
Till now I used
requests.Request.prepare().path_url
for the URL and yet sent aiohttp request, but I just found out that sometimes the argument ordering in the output URL will differ between the libraries. Nasty bug.My first reflex was to try with
ClientRequest
but it requries YARL's URL object (I think?), which is doable I guess, but maybe there's something short and sweet already available.Can you please help me out?
The text was updated successfully, but these errors were encountered: