Session cookies break requests-oauth

Hi,

requests 0.8 breaks <a href="https://github.com/maraujop/requests-oauth">requests-oauth</a>. See the related issue in requests-oauth:
https://github.com/maraujop/requests-oauth/issues/5

After debugging both together, I've found out the culprit is this line:
https://github.com/kennethreitz/requests/blob/develop/requests/sessions.py#L190

Cookies were not updated automatically in sessions before 0.8. If I add `self.cookies = {}` before sending the request, requests-oauth starts working again. 

Not sure if this is a bug or you want me to set cookies to an empty dictionary in my hook. 

Cheers,
Miguel


I don't see what the problem is, but the requests behavior is intentional.


How would cookies break your hook? 


Me neither, but trust me, if I set them to an empty dict, tests start passing again.

I thought you would have a clue about it. I'm guessing Twitter OAuth API doesn't support cookies?


Poking at this with Charles, so far the only difference I'm seeing is the presence of cookies on the 2nd request.

Gist: https://gist.github.com/1371423

Trying out other libraries to see how they behave. Suspecting that this is a bug with Twitter's API.


Definitely a bug with the Twitter API. Reported upstream: https://dev.twitter.com/discussions/3705.


Rdio API fails with this version of requests


My understanding was that Twitter supported specs 1.0 and 1.0a. I've tried removing `oauth_body_hash` and `oauth_verifier` and it breaks the same way. So it's not because passing those parameters with cookies at the same time.


I'm trying to implement something simple to pass the OAuth bits in headers, and see if they like that more. 

-I 

On Thursday, November 17, 2011 at 11:53 AM, Miguel Araujo wrote:

> My understanding was that Twitter supported specs 1.0 and 1.0a. I've tried removing `oauth_body_hash` and `oauth_verifier` and it breaks the same way. So it's not because passing those parameters with cookies at the same time.
> 
> ---
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/kennethreitz/requests/issues/272#issuecomment-2774121


Also as @juanriaza says, this is not an API specific thing, Rdio fails the same way and it was working before.


@idangazit

I've moved <a href="http://oauth.net/core/1.0/#auth_header">OAuth bits to headers</a>, but OAuth isn't working for a simple Twitter status POST example, so I must be doing something wrong, but I cannot catch the error.

```
Headers: {'Authorization': 'OAuth%20oauth_nonce%3D%2273947544%22%2C%20oauth_timestamp%3D%221321529518%22%2C%20oauth_consumer_key%3D%22CONSUMER_KEY%22%2C%20oauth_signature_method%3D%22HMAC-SHA1%22%2C%20oauth_version%3D%221.0%22%2C%20oauth_token%3D%OAUTH_TOKEN%22%2C%20oauth_signature%3D%225IYmrXKbEMp5npH%2FUrwcH0H%2FZ5s%3D%22', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'python-requests/0.8.1'}
URL: http://api.twitter.com/1/statuses/update.json
Params: {}
Data: {'status': 'Kind of a random message 0.862699448264', 'wrap_links': True}
2011-11-17T12:31:58.369048   POST   http://api.twitter.com/1/statuses/update.json
{"error":"Could not authenticate with OAuth.","request":"\/1\/statuses\/update.json"}
```

Can you spot anything wrong here? I've debugged it as much as possible.

Even though I'm not sure this will fix the cookies error, I think it's a good try. If you want to look at the code, I can put it in a branch.

Miguel


As this doesn't look any longer related to requests, but the problem seems to be in how OAuth API providers handle cookies. I've disabled cookies in requests-oauth and I'm closing both issues.

Cheers,
Miguel