Python/Requests: Correct login returns 401 unauthorized
<p>I have a python application logs in to a remote host via basic HTTP authentication. 
Authentication is as follows: </p>

<pre><code>def make_authenticated_request(host, username, password):
    url = host
    r = requests.get(url, auth=(username, password))
    r.raise_for_status()
    return r

test = Looter.make_authenticated_request("http://" + host + "/status/status_deviceinfo.htm", user, password)
</code></pre>

<p>This error is printed:  </p>

<p><code>401 Client Error: Unauthorized for url</code>  </p>

<p>Strange thing is that this doesn't always happen. It randomly fails/succeeds, for the same host with the same credentials. </p>

<p>Login is however correct, and works flawlessly in my browser. I'm no python ninja. Any clues ?</p>