Xamarin 表单 - 如何在 UWP 中从 Google 驱动器上传、删除、下载文件

Xamarin Form - How to upload,Delete,Download Files From Google Drive in UWP

你好朋友,我想在 Google 驱动器上上传图像和文件。所以我安装了 Google.Apis.AuthGoogle.Apis.Drive.v3 nuget 包。

我还通过引用视频 https://www.youtube.com/watch?v=xtqpWG5KDXYNow 创建了 Client_secrete.json 文件。问题,如何使用此 Client_secrete.json 文件以及从 uwp 中的 Google 驱动器上传、下载、删除文件? :(

如有任何想法,请分享代码或 link。

提前致谢:)...

  public static DriveService GetService()
    {
        UserCredential credential;
        DriveService service = new DriveService();
        using (var stream = new FileStream(destinationFolder.Path + @"\client_secret.json", FileMode.Open, FileAccess.Read))
        {
            String FolderPath = destinationFolder.Path;
            String FilePath = Path.Combine(FolderPath, 
"DriveServiceCredentials.json");
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "users",
                CancellationToken.None,
                new FileDataStore(FilePath, true)).Result;   // Here i got 
the exception.

            service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "DemoDrive",
            });

        }
        return service;

    }

当我尝试 运行 这段代码时,它给出了错误。 :( 如何解决这个问题.....

请勾选Google.Apis.Drive.v3, the nuget package incompatible platform contain uwp and Xamarin. So, you could not use it for xamarin.uwp app. For cloud drive within uwp platform, we suggest you use OneDrive to replace. And we have provide OneDrive Serviceapi可以立即实现云盘