我正在創(chuàng)建一個(gè) UWP 應(yīng)用程序,我想使用 Onedrive API,以便用戶可以在其 Onedrive 帳戶中保存文件的副本,但我不明白,到目前為止我只成功登錄了我想要的內(nèi)容:上傳文件下載文件如果其中任何一個(gè)被修改,則進(jìn)行同步創(chuàng)建文件夾刪除文件此代碼實(shí)現(xiàn)了登錄,但我無法超越此,就像繼續(xù)上傳文件或下載文件一樣 private async void btn_Login_Click(object sender, RoutedEventArgs e) { if (this.oneDriveClient == null) { try { // Setting up the client here, passing in our Client Id, Return Url, // Scopes that we want permission to, and building a Web Broker to // go do our authentication. this.oneDriveClient = await OneDriveClient.GetAuthenticatedMicrosoftAccountClient( clientId, returnUrl, scopes, webAuthenticationUi: new WebAuthenticationBrokerWebAuthenticationUi()); // Show in text box that we are connected. txtBox_Response.Text = "We are now connected"; // We are either just autheticated and connected or we already connected, // either way we need the drive button now. btn_GetDriveId.Visibility = Visibility.Visible; }我在 github 中創(chuàng)建了一個(gè)示例存儲(chǔ)庫:Onedrive Sync Files Sample我已經(jīng)嘗試過使用 Dropbox、Gdrive,但它在 UWP 上的實(shí)現(xiàn)似乎要復(fù)雜得多,所以我選擇了 OneDrive。任何答案都會(huì)非常有幫助,提前致謝
1 回答

牧羊人nacy
TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超7個(gè)贊
如何在 C# 中使用 OneDrive API 同步文件
對于使用 OneDrive,我們建議您使用Windows 社區(qū)工具包中的OneDrive服務(wù)來實(shí)現(xiàn) OneDrive功能。
入門
要使用 OneDrive API,您需要擁有一個(gè)訪問令牌,用于對您的應(yīng)用程序進(jìn)行身份驗(yàn)證,以獲得用戶的一組特定權(quán)限。在本節(jié)中,您將學(xué)習(xí)如何:
注冊您的應(yīng)用程序以獲取客戶端 ID 和客戶端密鑰。
使用令牌流或代碼流將用戶登錄到具有指定范圍的 OneDrive。
將用戶注銷(可選)。
- 1 回答
- 0 關(guān)注
- 250 瀏覽
添加回答
舉報(bào)
0/150
提交
取消