我在使用C#Yandex磁盘API时遇到问题

时间:2020-07-23 10:42:41

标签: c# yandex yandex-api

我想使用Yandex磁盘API。但是我在互联网上找到的有关此事的示例并没有帮助我。 我在这里查看了链接:https://github.com/raidenyn/yandexdisk.client 但是我找不到如何获取oauthToken。 我在这里查看了链接:https://github.com/yandex-disk/yandex-disk-sdk-csharp 但是,当我尝试使用代码时,出现了错误。 我使用了Google Drive API,并完成了所有操作。 Internet上有足够的资源和示例。但是我找不到有关Yandex Disk的信息。

async Task UploadSample()
        {
            string oauthToken = "";

            IDiskApi diskApi = new DiskHttpApi(oauthToken);

            //Upload file from local
            await diskApi.Files.UploadFileAsync(path: "/myfile.txt",
                                                overwrite: true,
                                                localFile: @"C:\Users\buraksayici\Desktop\drive big file.txt",
                                                cancellationToken: CancellationToken.None);
        }

如何打开oauth令牌? Google云端硬盘会打开自动的网络浏览器并获取必要的令牌。但是我在互联网上找不到这样的例子。 我在等待您的帮助,谢谢。

https://github.com/yandex-disk/yandex-disk-sdk-csharp

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;

我在此代码中也遇到了这样的错误:

Error

0 个答案:

没有答案