1

Hello friend I want to upload an images,files on Google Drive. So I have installed the Google.Apis.Auth and Google.Apis.Drive.v3 nuget packages.

I have also created the Client_secrete.json file by referring video https://www.youtube.com/watch?v=xtqpWG5KDXYNow. Question, how to use this Client_secrete.json file and upload, download, delete the files from the Google Drive in uwp ? :(

Any idea then please share code or link.

Thanks in advance :)...

  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;

    }

When i am trying to run this code it gives error. :( how to solve this.....

enter image description here

1 Answers1

0

Please check 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 Service api that could implement cloud drive immediately.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Thank you for your valuable reply. [link](https://github.com/googlesamples/oauth-apps-for-windows/blob/master/OAuthUniversalApp/README.md) then what is the use of this google Oath sample ? what if i want to store my data on google drive ? is their any third party dll ? –  May 24 '19 at 07:24
  • @ketan, This case [reply](https://stackoverflow.com/a/39760255/7254781) may helpful. – Nico Zhu May 24 '19 at 07:41
  • OneDrive support for the UWP windows app ? if support then please share some code or links. which nuget package should i install ? thank you :) –  May 24 '19 at 09:57
  • Please check this code sample [link](https://learn.microsoft.com/en-us/windows/communitytoolkit/services/onedrive#sample-code). Please install [`Microsoft.Toolkit.Uwp`](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp/) nuget package. – Nico Zhu May 24 '19 at 10:00
  • do you have any other code sample i don't understand the above link :( –  May 24 '19 at 10:45
  • i have downloaded the uwp sample project form given [link](https://github.com/googlesamples/oauth-apps-for-windows) but i don't how its works do you have an idea. –  Aug 13 '19 at 09:58
  • do you have any idea ? –  Aug 13 '19 at 13:15
  • Please try to run this uwp [project](https://github.com/googlesamples/oauth-apps-for-windows/tree/master/OAuthUniversalApp). – Nico Zhu Aug 13 '19 at 13:18
  • i am not getting how to set the redirectUrl ? where is it ? i have followed every steps but where is the redirect url ? –  Aug 13 '19 at 13:22
  • sorry man, currently, google production is not in our support scope. – Nico Zhu Aug 13 '19 at 13:26
  • you mean to say i cant implement this project logic into my uwp application ? –  Aug 13 '19 at 13:52
  • I mean I have not used this sample, So I could not explain `redirectUrl` clearly. – Nico Zhu Aug 13 '19 at 13:56