2017-02-22 90 views
1

我期待列出已與我共享OneDrive業務使用Python SDK OneDrive(onedrive的Python-SDK)列表共享文件OneDrive業務

我已經成功地驗證,能夠文件列出我已經用下面的代碼

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 

任何幫助,將不勝感激

回答

0

我的前綴,它的答案與我沒有設置驗證這條巨蟒的解決方案的環境中的免責聲明,但我相信它應該工作(或最壞情況爲您提供解決問題的想法)。

你是正確的,因爲目前的SDK不會公開view.sharedWithMe,但它很幸運地包含你需要自己做的工具。你會想結合使用append_to_request_url功能與ItemsCollectionRequestBuilder像這樣:

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

希望這會給你,你之後的結果。

+0

謝謝你的快速回答,這工作絕對對待! – user29184827194701

+0

@ user29184827194701您可以在何處下載文件? – Sid29

相關問題