首页 > 解决方案 > 查找“与我共享”文件夹 ID(驱动器 ID)和文件 ID - OneDrive、Microsoft Graph、Python

问题描述

我的客户与我共享了一些包含 5 个文件的 onedrive 文件夹,我想找到驱动器 ID,文件 ID,以便我可以使用 python 脚本下载,脚本参考:无法从文件夹内下载文件,OneDrive,Microsoft图形,Python

我正在尝试以下脚本:

requests.get('https://graph.microsoft.com/v1.0/me/drive/sharedWithMe', headers={'Authorization': 'Bearer ' + Access_Token}).content

requests.get('https://graph.microsoft.com/v1.0/me/drives', headers={'Authorization': 'Bearer ' + Access_Token}).content

但我只获取我的文件详细信息。

标签: python-3.xpython-requestsazure-active-directorymicrosoft-graph-apionedrive

解决方案


您可以先调用urihttps://graph.microsoft.com/v1.0/me/drive/sharedWithMe并获取响应数据。在响应中,我们可以找到共享文件的idand driveId(“driveId”在“remoteItem”->“parentReference”下)。然后使用下面的 api 下载它的内容。

https://graph.microsoft.com/v1.0/me/drives/{driveId}/items/{id}/content

推荐阅读