where are my upload to google drive's files for service account

冷暖自知 提交于 2019-12-12 04:56:52

问题


I have the code below that uploads a file to my Google service account. It is working, but I want to know where is the file? Which account can I use to login to google drive and get the file and how much space can I use? Is there anything like google drive UI for service accounts?

private static Google.Apis.Drive.v2.Data.File insertFile(
      String title, 
      String mimeType, 
      MemoryStream FileStream)
    {
        String serviceAccountEmail = "XXXXXX@developer.gserviceaccount.com";

        var certificate = new X509Certificate2(
             @"XXXXXXprivatekey.p12", 
             "notasecret", 
             X509KeyStorageFlags.Exportable);

        ServiceAccountCredential credential = new ServiceAccountCredential(
           new ServiceAccountCredential.Initializer(serviceAccountEmail)
           {
               Scopes = new[] { DriveService.Scope.Drive }
           }.FromCertificate(certificate));

        // Create the service.
        DriveService service = new DriveService(
                                   new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Drive API Sample",
        });

        // File's metadata.
        Google.Apis.Drive.v2.Data.File body = 
                  new Google.Apis.Drive.v2.Data.File();
        body.Title = title;
        body.Description = title;
        body.MimeType = mimeType;

        FilesResource.InsertMediaUpload request = 
              service.Files.Insert(body, FileStream, mimeType);
        request.Upload();

        Google.Apis.Drive.v2.Data.File file = request.ResponseBody;

        return file;
    }

回答1:


There is no UI for Service Accounts. The files are only accessible to your app.



来源:https://stackoverflow.com/questions/22246421/where-are-my-upload-to-google-drives-files-for-service-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!