Python Requests giving response 401
<p>I am downloading the data from API but getting error 401:
I understand the error 401 but dont know what is wrong in my code.</p>

<pre><code>import json
import requests
path='C:/Users/sharm_000/Desktop/Price Comparison/'

cat=str('https://affiliate-api.flipkart.net/affiliate/api/swapnilsh5.json')
r = requests.get(cat, auth=('swapnilsh5', '7018e1141bcd4ace9c3fe12277924035'))
print (r)
</code></pre>

<p>the above code returns 201 response which is great, but the challenge comes when i go for next level of data download</p>

<pre><code>link='https://affiliate-api.flipkart.net/affiliate/1.0/feeds/swapnilsh5/category/j9e-abm-c54.json?expiresAt=1479062969473&amp;sig=1ef27c056140e0ff7cac143670584e9d&amp;inStock=1'

r = requests.get(str(link), auth=('swapnilsh5', '7018e1141bcd4ace9c3fe12277924035'))

print(r)
</code></pre>

<p>this return 401 error, this i am not able to figure out, when I run the above link using curl</p>

<pre><code>curl -H "Fk-Affiliate-Id:swapnilsh5" -H "Fk-Affiliate-Token:7018e1141bcd4ace9c3fe12277924035" "https://affiliate-api.flipkart.net/affiliate/1.0/feeds/swapnilsh5/category/j9e-abm-c54.json?expiresAt=1479062969473&amp;sig=1ef27c056140e0ff7cac143670584e9d&amp;inStock=1" -o "C:\Users\sharm_000\Desktop\Price Comparison\a1c.json"
</code></pre>

<p>The curl commands work absolutely fine.</p>

<p>Please suggest where I am going wrong and what would be the other ways of doing the same task in python.</p>

<p>Thanks in Advance.</p>