我们想要使用yandex磁盘api。用户可以使用yandex磁盘上传和删除文件。
我想从登录页面获取令牌。我尝试了很多sdk,但找不到正常工作的示例代码。
你能帮忙吗?我使用https://github.com/yandex-disk/yandex-disk-sdk-csharpsdk
但是sdk是WPF我使用winform
this.sdkClient.AuthorizeAsync(new WebBrowserBrowser(browser), CLIENT_ID, RETURN_URL, this.CompleteCallback);
…
private void CompleteCallback(object sender, GenericSdkEventArgs<string> e)
{
if (this.AuthCompleted != null)
{
this.AuthCompleted(this, new GenericSdkEventArgs<string>(e.Result));
}
this.Close();
}
public event EventHandler<GenericSdkEventArgs<string>> AuthCompleted;
在GitHub页面底部实现问题的解决方案:https://github.com/raidenyn/yandexdisk.client
// PM> Install-Package YandexDisk.Client
using YandexDisk.Client.Http;
using YandexDisk.Client.Clients;
namespace Yandex_Disk
{
class Yandex_Disk_Functions
{
private const string Token = "AgADAASAUssBGGAADSFfcRFRBurE1Rstu0WtsR7-d2";
internal static async void UpLoad(string DiskPath, string LocalPath) =>
await new DiskHttpApi(Token).Files.UploadFileAsync(DiskPath, false, LocalPath, CancellationToken.None);
internal static async void DownLoad(string DiskPath, string LocalPath) =>
await new DiskHttpApi(Token).Files.DownloadFileAsync(DiskPath, LocalPath);
}
}