I need to get list of files from google drive with asp.net mvc4 project. Google Drive is used as a file storage for the site. My code:
const string email = "xxx";
string path = AppDomain.CurrentDomain.BaseDirectory + "file.p12";
var certificate = new X509Certificate2(path,"notasecret", X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(email){
Scopes = new[] { DriveService.Scope.Drive }
}.FromCertificate(certificate));
var service = new DriveService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName="hikes"
});
List<File> result = new List<File>();
FilesResource.ListRequest request = service.Files.List();
do
{
FileList files = request.Execute();
result.AddRange(files.Items);
request.PageToken = files.NextPageToken;
} while (!String.IsNullOrEmpty(request.PageToken));
Tried on two different accounts. The result is only one pdf file called "How to get started with Drive". How do I get access to the files of my disk?