I am trying to upload a CSV of a Pandas DataFrame generated by a Python script to Microsoft SharePoint / OneDrive.
I cannot figure out how to get past the following error when I try to connect to upload a file:
import pandas as pd
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.authentication_context import AuthenticationContext
df = pd.DataFrame()
site_url = "https://{tenant id: str = ########-####-####-####-############ ???}.sharepoint.com/sites/{site name: str = 'tktktk' ???}"
username = "{user}@{site name}.com"
password = "{tktktk}"
auth_ctx = AuthenticationContext(site_url)
auth_ctx.acquire_token_for_user(username, password)
ctx = ClientContext(site_url, auth_ctx)
web = ctx.web
ctx.load(web)
try:
ctx.execute_query()
print(f"Connection to SharePoint site '{web.properties['Title']}' successful!")
except Exception as e:
print(f"Error connecting to SharePoint: {e}")
Output:
ValueError: Cannot get binary security token for from https://login.microsoftonline.com/extSTS.srf