Error 403 when downloading excel file from SharePoint using Python script

I amm trying to download an excel file from my company's SharePoint repository automatically using Python instead of doing it mannually. I adaped the code from Download excel files from SharePoint document library using python

My problem is I always got Error 403 and an empty .xlsx file even thogh I entered my password and username corretly. Can someone please help me? Thank you a lot.

Here is my code:

import requests
from requests.auth import HTTPBasicAuth
file =  "https://company.sharepoint.com/:x:/r/sites/path~/file_name.xlsx"

username = input("Enter your username: ") 
password = getpass("Enter your password: ")

response = requests.get(file, auth=HTTPBasicAuth(username, password))
output = open('test.csv', 'wb')
output.write(response.content)
output.close()


from Recent Questions - Stack Overflow https://ift.tt/3znCHFM
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)