如何通过onedrivesdk使用共享链接访问OneDrive文件夹

时间:2019-07-06 12:02:04

标签: python onedrive

我正在尝试使用共享链接访问OneDrive上的文件夹。我想做的只是使用网络应用向API进行身份验证,然后将调用相应的方法。我正在尝试执行此操作,而无需用户登录,也没有手动的身份验证方法。

这是我已经做的:

import base64
import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer

# url = "https://onedrive.live.com/?authkey=%21AKgIsaYoSnA2Q8w&id=8DCB92C25A21A711%2136410&cid=8DCB92C25A21A711"
# b = url.encode("UTF-8")
# e = base64.b64encode(b)
# s1 = e.decode("UTF-8")
# encodedUrl = "u!" + s1
# final_url = "https://graph.microsoft.com/v1.0/shares/" + encodedUrl + "/driveItem?$expand=children"
# print("Final_url: " + final_url)

redirect_uri = "http://localhost:8080/"
client_id = "e463867e-0813-4023-abd4-593d3438973a"
client_secret = "secret-here"
scopes=['onedrive.readwrite']

client = onedrivesdk.get_default_client(
    client_id=client_id, scopes=scopes)

auth_url = client.auth_provider.get_auth_url(redirect_uri)

#this will block until we have the code
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)

client.auth_provider.authenticate(code, redirect_uri, client_secret)

collection = ...
print(collection)

现在在集合变量中,我应该称呼client.shares我相信还是其他?

有人可以指出我正确的方向吗?

0 个答案:

没有答案