在我们的一个环境中,我们有以下的Python代码already working like a champ:

def download_files_to_dbfs (site_url, file_url, dbfs_path):
  try:
    # Credentials for accessing SharePoint
        credentials = ClientCredential("Client-ID?",
                                       "Client-Secret?")
        ctx = ClientContext(site_url).with_credentials(credentials)

        # File_url is the sharepoint url from which you need the list of files
        list_source = ctx.web.get_folder_by_server_relative_url(file_url)
        files = list_source.files
        ctx.load(files)
        ctx.execute_query()

        for myfiles in files:
            rel_url = myfiles.properties["ServerRelativeUrl"]
            download_path = dbfs_path + myfiles.properties["Name"]

            with open(download_path, "wb") as local_file:
                 file = ctx.web.get_file_by_server_relative_path(rel_url).download(local_file).execute_query()
                 print("Downloaded file " + myfiles.properties["Name"])

  except Exception as e:
    print(e)

我们被授予了自己的工作空间,我们实际上是那里的管理员. 问题是,即使我们的SharePoint admin已经建立了到SharePoint的客户端秘密连接,我们仍然无法通过切换到新的Client-SecretClient-ID来使用相同的功能访问SharePoint. 在上面的代码中,我将"Client-ID?""Client-Secret?"放在引号中,因为我不确定正确的顺序,也不确定这两个元素是否是在SharePoint和Databricks之间建立连接所需的元素. 我们遇到的错误是Acquire app-only access token failed,没有提供更多详细信息,只有错误消息本身.我们已经挣扎了好几个星期了:(...

推荐答案

在@Evandro de Paula好心地建议我如何继续之后,我终于得出结论,这是一个防火墙问题.多么?我将回溯添加到我的函数中,以检测错误的更多细节...我希望这对其他人也有帮助.

Python-3.x相关问答推荐

根据收件箱内部的值以行降序的特定顺序重新排序列

为什么打印语句在Python多处理脚本中执行两次?

如何将值映射到具有上限和下限的新列

Python webdrivermanager 和 Chrome 115.0 的 URL https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790 错误没有此类驱动程序

重复数组直到一定长度 groupby pandas

Pandas groupby 然后 for each 组添加新行

在不改变 python 中原始数组顺序的情况下,对多维字符串数组进行降序排序?

如何将虚拟变量列转换为多列?

Semaphore信号量 Python 的工作原理

活动屏幕上的 PyQt4 中心窗口

在python中基于列表理解的条件下跳过元素

使用 Python 3 按行进行分析

如何用pymongo连接远程mongodb

如何获得 BeautifulSoup 标签的所有直接子代?

在 WSL (Ubuntu) 中为 python3 安装 venv

在 Python 3 中调用 super() 的 4 种方法中的哪一种?

TypeError:多个基地有实例布局冲突

python asyncio add_done_callback 与 async def

在 PyCharm 中配置解释器:请使用不同的 SDK 名称

Python:如何在 Windows 资源管理器中打开文件夹(Python 3.6.2、Windows 10)