I want to download files from an dashboard environment in a python script and manipulate the data in the files. The dashboard environment needs me to login twice. I first need to login into a corporate account and then into a personal account. I can login into the corporate account, but then the login into my personal account fails while I do provide the correct credentials.
This is the script I'm trying to use. The stuff between the stars is changed for privacy reasons:
import csv
import requests
URL_Login = '*baseurl of the dashboard*'
CSV_URL = '*baseurl of the dashboard*/auto/reports/responses/?sheet=1528&item=4231&format=csv'
with requests.Session() as s:
download = s.get(URL_Login, auth=("*corporate account name*", "*corporate password*"))
download = s.get(CSV_URL, auth=("*personal account name*", "*personal password*"))
decoded_content = download.content.decode('utf-8')
cr = csv.reader(decoded_content.splitlines(), delimiter=',')
my_list = list(cr)
for row in my_list:
print(row)
I get the following error message: 401 - Unauthorized: Access is denied due to invalid credentials. You do not have permission to view this directory or page using the credentials that you supplied.
Can anything else trigger the 401, because I am very sure I'm providing the correct credentials?