Python 在OneDrive for business中列出共享文件

Python 在OneDrive for business中列出共享文件,python,onedrive,Python,Onedrive,我希望列出在OneDrive for business上使用Python OneDrive SDK(OneDrive Python SDK)与我共享的文件 我已经成功地通过了身份验证,并且能够使用以下代码列出我拥有的文件 import onedrivesdk from onedrivesdk.helpers import GetAuthCodeServer from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRe

我希望列出在OneDrive for business上使用Python OneDrive SDK(OneDrive Python SDK)与我共享的文件

我已经成功地通过了身份验证,并且能够使用以下代码列出我拥有的文件

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest

redirect_uri = 'http://localhost:8080'
client_id = your_client_id
client_secret = your_client_secret
discovery_uri = 'https://api.office.com/discovery/'
auth_server_url='https://login.microsoftonline.com/common/oauth2/authorize'
auth_token_url='https://login.microsoftonline.com/common/oauth2/token'

http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http,
                                client_id,
                                auth_server_url=auth_server_url,
                                auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)
# If you have access to more than one service, you'll need to decide
# which ServiceInfo to use instead of just using the first one, as below.
service_info = ResourceDiscoveryRequest().get_service_info(auth.access_token)[0]
auth.redeem_refresh_token(service_info.service_resource_id)
client = onedrivesdk.OneDriveClient(service_info.service_resource_id + '/_api/v2.0/', auth, http)

#get the top three elements of root, leaving the next page for more elements
collection = client.item(drive='me', id='root').children.request(top=3).get()
# print files
print collection
但是,我不确定如何请求与我共享的文件,我在OneDrive API中看到了使用以下请求的引用,但我不确定如何进行调用

GET /drive/view.sharedWithMe

任何帮助都将不胜感激

我将在回答之前声明,我没有设置验证此python解决方案的环境,但我相信它应该可以工作(或者在最坏的情况下为您提供解决方案的想法)

您是正确的,因为当前SDK没有公开
视图.sharedWithMe
,不过,谢天谢地,它包含了您自己做这件事所需的工具。您需要将
append\u to\u request\u url
功能与
ItemsCollectionRequestBuilder
结合使用,如下所示:

collection = ItemsCollectionRequestBuilder(client.drive.append_to_request_url("view.sharedWithMe"), client).request(top=3).get()

希望这将为您提供您想要的结果。

我将在回答之前声明,我没有设置验证此python解决方案的环境,但我相信它应该可以工作(或者在最坏的情况下为您提供解决方案的想法)

您是正确的,因为当前SDK没有公开
视图.sharedWithMe
,不过,谢天谢地,它包含了您自己做这件事所需的工具。您需要将
append\u to\u request\u url
功能与
ItemsCollectionRequestBuilder
结合使用,如下所示:

collection = ItemsCollectionRequestBuilder(client.drive.append_to_request_url("view.sharedWithMe"), client).request(top=3).get()

希望这能给你带来你想要的结果。

谢谢你的快速回答,这真是一次难得的享受@用户29184827194701您以后可以在哪里下载该文件?感谢您的快速回答,这是一个绝对的享受@用户29184827194701您以后可以在哪里下载该文件?