0

I would like to query files uploaded to google drive folder by C# desktop application from an android application.I use google drive API to upload files from C# application with OAuth 2.0 client that i have created in google console. Then i try to get list of files from an android application(using Xamarin.Android) with another OAuth 2.0 android client under same project.Part off code to retrieve files is shown here:

this.GoogleApiClient = new Android.Gms.Common.Apis.GoogleApiClient.Builder(Android.App.Application.Context)
               .AddApi(Android.Gms.Drive.DriveClass.API)
               .AddScope(Android.Gms.Drive.DriveClass.ScopeFile)
               .SetAccountName("xxxx@gmail.com")
               .AddConnectionCallbacks(this)
               .AddOnConnectionFailedListener(this)
               .Build();

GoogleApiClient.Connect();

var query = new Android.Gms.Drive.Query.QueryClass.Builder().AddFilter(Android.Gms.Drive.Query.Filters.Contains(Android.Gms.Drive.Query.SearchableField.Title, "apps.txt")).Build();    

var results = await Android.Gms.Drive.DriveClass.DriveApi.Query(googleApiClient, query).AsAsync<Android.Gms.Drive.IDriveApiMetadataBufferResult>();

But it seems that Android.Gms.Drive.DriveClass.ScopeFile returns only files that have been uploaded by same application. It seems a similar question with the one raised here:

Android app, Desktop c# app sharing Google Drive App Data

I wonder if i can add some specific metadata to the files uploaded by C# in order android google API to be able to return these files while querying. Or make some specific configuration in clients configured in google console under same account.

Community
  • 1
  • 1
  • Drive API returns the same results regardless of framework or programming language used as long as your following the correct methods indicated in the API. That method would be [Files.list](https://developers.google.com/drive/v3/reference/files/list). Although not exactly the same, try referring to this [.NET Quickstart](https://developers.google.com/drive/v3/web/quickstart/dotnet) on how to list files since Xamarin also uses .NET language. – ReyAnthonyRenacia Apr 27 '17 at 14:04
  • I am using google drive android API to query files and not REST API.Android.Gms.Drive.DriveClass.ScopeFile returns only files that have been uploaded by same application. However i added OAuth 2.0 clients(desktop and android) under same google console project and it seems that now it works. Thanks anyway for your answer – dpettas May 11 '17 at 13:00
  • If you want, you can post your code which might be of help to the community. – ReyAnthonyRenacia May 11 '17 at 19:21

0 Answers0