1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Issue uploading CSV to SharePoint from Python

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    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

    Continue reading...

Compartilhe esta Página