Teck
Teck

Reputation: 85

Python Request .csv 401 Client Error: Unauthorized for URL

I am trying to download a csv file from an authorized website.

I am able to get respond code of 200 with url https://workspace.xxx.com/abc/ (click in this web page to download the csv) but respond code of 401 at url = 'https://workspace.xxx.com/abc/abc.csv'

This is my code:

import requests
r = requests.get(url, auth=('myusername', 'mybasicpass'))

I tried adding header and using session but still get respond code of 401.

Upvotes: 0

Views: 1755

Answers (1)

Swapnil Suryawanshi
Swapnil Suryawanshi

Reputation: 354

First of all, you have to investigate how the website accepts the password. They might be using HTTP authentication or Authorization header in the request. You can log in using their website and then download the file .study how they are passing authorization. I am sure they are not accepting plain passwords in authorization they might be encoding it in base64 or another encoding scheme.

My advice to you is to open the developer console and study their requests in network tab. You can post more information so one could help you more.

Upvotes: 0

Related Questions