After a few tentatives and seeing a lot of examples and questions around here I can't figure out why I'm not able to download a file using requests module, the File i'm trying to download is around 10mb only:
try:
r = requests.get('http://localhost/sample_test', auth=('theuser', 'thepass'), stream=True)
with open('/tmp/aaaaaa', 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
f.write(chunk)
except:
raise
Empty file:
[xxx@xxx ~]$ ls -ltra /tmp/aaaaaa
-rw-rw-r--. 1 xxx xxx 0 Jul 21 12:38 /tmp/aaaaaa
EDIT: I just discovered that it's necessary to authenticate into the API with session instead basic authentication, that information wasn't available on the specification. The code above works properly. I voted to close this question.