Gets info from sharepoint excel file

PHOTO EMBED

Tue Feb 01 2022 08:12:54 GMT+0000 (Coordinated Universal Time)

Saved by @Vicktoria77 #python

url = 'https://cchellenic.sharepoint.com/:x:/s/DataProject/EQBBeHbyS8VCuzpQHhE0WxgBQjDtvysYnoUej-KIzeC6Rw?e=nVRbNQ'
username = 'email'
password = 'parola'

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
  ctx = ClientContext(url, ctx_auth)
  web = ctx.web
  ctx.load(web)
  ctx.execute_query()
  print("Authentication successful")

response = File.open_binary(ctx, url)

#save data to BytesIO stream
bytes_file_obj = io.BytesIO()
bytes_file_obj.write(response.content)
bytes_file_obj.seek(0) #set file object to start

#read excel file and each sheet into pandas dataframe
df = pd.read_excel(bytes_file_obj, sheetname = "OHD Structure")
content_copyCOPY

ValueError: An error occurred while retrieving token from XML response: AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access ''.