Closed jmoiron closed 12 years ago
I believe this has changed recently.
request.params is indeed a dictionary in requests-0.13.1, which means the code in this ticket no longer works and the _enc_params = urlencode(...)
step is no longer necessary for auth using params.
@jmoiron @kennethreitz I'm sorry, but how can it be currently done? Building API client for another service that uses signature-based authentication and when I'm trying to add parameters by editing r.params, I receive: AttributeError: 'PreparedRequest' object has no attribute 'params'
@pitsevich the API has changed in the most recent releases of requests. As of 1.x you have no access to the params attribute. If you want to modify the params you'll have to parse the url and unquote the param string, add your params, re-quote it and then unparse the url.
@sigmavirus24 thanks, this worked!
@pitsevich glad to help.
Because
_enc_params
seems to already be built by the time auth is applied, and r.params is no longer a dictionary, authentication schemes that require signatures to be passed as a param (like LastFM's, possibly others) end up being kind of unwieldy. Here's some working LastFM auth code, for example:I think it would suffice to delay setting
_enc_params
until after auth is applied; even if such a thing is documented it still feels kind of strange.