Broken with update of python-requests
mart-e opened this issue · 3 comments
An update of requests seems to have broken the package. The most notably is the creation of sessions where it used to work with request.session(hooks=...)
. The current version of requests does not accept any arguments for the constructor. I don't know exactly when it happened as I haven't used the package for some time.
However I guess there is more problems because moving the hooks parameter outside the constructor does not fix the problem. It seems that the parameters used in the hooks
are not sent with the request. The test suite fails for 9 of the 13 Twitter tests (haven't tested for other networks).
Version of python-requests used : 1.0.3-1
Yeah they removed the pre_request event. Not sure how it can work otherwise. Update requirements requests==0.14.2.
The author off requests created request-oauthlib that uses oauthlib. I haven't look how they did it there but maybe there is inspiration t take.
hey guys, i figured how to use the current version of requests... here's some sample code. Hope this helps someone!
OAuthHook.consumer_key = consumer_key
OAuthHook.consumer_secret = consumer_secret
oauth_hook = OAuthHook(access_token, access_token_secret, header_auth=True)
request = requests.Request('POST', url, data=parameters, files=files)
request = oauth_hook(request)
session = requests.session()
response = session.send(request.prepare(), timeout=timeout)
result = response.json()