Cannot download files anymoreDrive API download without loginGoogle Drive API - Queries randomly fail on TokenResponseException (Invalid Request/Internal Failure)Google API to upload files using the Authentication Service AccountDownload files from google driveGoogle API: ServiceAccount errors with DirectoryService and DriveService using C#Google Drive API v3 use JSON instead of P12 (Service Account) - Unexpected characterHow to change the created name shown on file details in Google Drive when using C# Google Drive API with OAuth to upload a file?How to view files added through google service accountGoogle Drive Service Account - file list returns only a file named “Getting started”Google API file create permissions

Pre-mixing cryogenic fuels and using only one fuel tank

How to explain what's wrong with this application of the chain rule?

Loading commands from file

What should you do if you miss a job interview (deliberately)?

Why electric field inside a cavity of a non-conducting sphere not zero?

What is Cash Advance APR?

Multiplicative persistence

Delivering sarcasm

Why do compilers behave differently when static_cast(ing) a function to void*?

Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?

Fear of getting stuck on one programming language / technology that is not used in my country

Closed-form expression for certain product

Why is it that I can sometimes guess the next note?

why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`?

Approximating irrational number to rational number

How can "mimic phobia" be cured or prevented?

"Spoil" vs "Ruin"

Count the occurrence of each unique word in the file

It grows, but water kills it

If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?

Longest common substring in linear time

Store Credit Card Information in Password Manager?

Why did the EU agree to delay the Brexit deadline?

Why should universal income be universal?



Cannot download files anymore


Drive API download without loginGoogle Drive API - Queries randomly fail on TokenResponseException (Invalid Request/Internal Failure)Google API to upload files using the Authentication Service AccountDownload files from google driveGoogle API: ServiceAccount errors with DirectoryService and DriveService using C#Google Drive API v3 use JSON instead of P12 (Service Account) - Unexpected characterHow to change the created name shown on file details in Google Drive when using C# Google Drive API with OAuth to upload a file?How to view files added through google service accountGoogle Drive Service Account - file list returns only a file named “Getting started”Google API file create permissions













4















I've got a system where we're using a Service Account to connect to the Google Drive SDK. It's been working fine for about 6 months, but starting a week ago, with no code changes, it's no longer able to download files from the Google Drive. We're still able to List files, but downloads are now bouncing to an authorization page rather than downloading the file. I'm certain that my Service Account has permissions to the file.



To down the file, I use the following code:



var downloader = new MediaDownloader(driveService);
var stream = new MemoryStream();
var download = await downloader.DownloadAsync(file.Url, stream);
if (download.Exception != null) throw download.Exception;
// Reset to the begining for replay
stream.Seek(0, SeekOrigin.Begin);
return stream;









share|improve this question
























  • What scope are you using? Check the directory and the file permissions to be sure the service account has access.

    – DaImTo
    Mar 8 at 7:12











  • My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

    – heneryville
    Mar 11 at 15:23











  • Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

    – Simon Mourier
    Mar 12 at 8:02











  • Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

    – Andrew Harris
    Mar 13 at 21:56











  • Are you using API v2 or v3?

    – AwonDanag
    Mar 14 at 4:10
















4















I've got a system where we're using a Service Account to connect to the Google Drive SDK. It's been working fine for about 6 months, but starting a week ago, with no code changes, it's no longer able to download files from the Google Drive. We're still able to List files, but downloads are now bouncing to an authorization page rather than downloading the file. I'm certain that my Service Account has permissions to the file.



To down the file, I use the following code:



var downloader = new MediaDownloader(driveService);
var stream = new MemoryStream();
var download = await downloader.DownloadAsync(file.Url, stream);
if (download.Exception != null) throw download.Exception;
// Reset to the begining for replay
stream.Seek(0, SeekOrigin.Begin);
return stream;









share|improve this question
























  • What scope are you using? Check the directory and the file permissions to be sure the service account has access.

    – DaImTo
    Mar 8 at 7:12











  • My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

    – heneryville
    Mar 11 at 15:23











  • Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

    – Simon Mourier
    Mar 12 at 8:02











  • Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

    – Andrew Harris
    Mar 13 at 21:56











  • Are you using API v2 or v3?

    – AwonDanag
    Mar 14 at 4:10














4












4








4


1






I've got a system where we're using a Service Account to connect to the Google Drive SDK. It's been working fine for about 6 months, but starting a week ago, with no code changes, it's no longer able to download files from the Google Drive. We're still able to List files, but downloads are now bouncing to an authorization page rather than downloading the file. I'm certain that my Service Account has permissions to the file.



To down the file, I use the following code:



var downloader = new MediaDownloader(driveService);
var stream = new MemoryStream();
var download = await downloader.DownloadAsync(file.Url, stream);
if (download.Exception != null) throw download.Exception;
// Reset to the begining for replay
stream.Seek(0, SeekOrigin.Begin);
return stream;









share|improve this question
















I've got a system where we're using a Service Account to connect to the Google Drive SDK. It's been working fine for about 6 months, but starting a week ago, with no code changes, it's no longer able to download files from the Google Drive. We're still able to List files, but downloads are now bouncing to an authorization page rather than downloading the file. I'm certain that my Service Account has permissions to the file.



To down the file, I use the following code:



var downloader = new MediaDownloader(driveService);
var stream = new MemoryStream();
var download = await downloader.DownloadAsync(file.Url, stream);
if (download.Exception != null) throw download.Exception;
// Reset to the begining for replay
stream.Seek(0, SeekOrigin.Begin);
return stream;






c# google-api google-drive-sdk google-api-dotnet-client






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 7:12









DaImTo

46.5k1166246




46.5k1166246










asked Mar 8 at 4:47









heneryvilleheneryville

1,75511526




1,75511526












  • What scope are you using? Check the directory and the file permissions to be sure the service account has access.

    – DaImTo
    Mar 8 at 7:12











  • My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

    – heneryville
    Mar 11 at 15:23











  • Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

    – Simon Mourier
    Mar 12 at 8:02











  • Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

    – Andrew Harris
    Mar 13 at 21:56











  • Are you using API v2 or v3?

    – AwonDanag
    Mar 14 at 4:10


















  • What scope are you using? Check the directory and the file permissions to be sure the service account has access.

    – DaImTo
    Mar 8 at 7:12











  • My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

    – heneryville
    Mar 11 at 15:23











  • Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

    – Simon Mourier
    Mar 12 at 8:02











  • Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

    – Andrew Harris
    Mar 13 at 21:56











  • Are you using API v2 or v3?

    – AwonDanag
    Mar 14 at 4:10

















What scope are you using? Check the directory and the file permissions to be sure the service account has access.

– DaImTo
Mar 8 at 7:12





What scope are you using? Check the directory and the file permissions to be sure the service account has access.

– DaImTo
Mar 8 at 7:12













My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

– heneryville
Mar 11 at 15:23





My scopes are DriveService.Scope.DriveFile, DriveService.Scope.Drive. My service account has access to both the directory and the file. I'm able to list the file, and can see the service account on the permissions. Also recall that this DID work, then mysteriously stopped working, with no code changes, so I don't think it's likely to be a a scoping issue.

– heneryville
Mar 11 at 15:23













Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

– Simon Mourier
Mar 12 at 8:02





Does the official sample github.com/google/google-api-dotnet-client-samples/tree/master/… works as is if you just change your auth parameters?

– Simon Mourier
Mar 12 at 8:02













Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

– Andrew Harris
Mar 13 at 21:56





Any chance you've got some restrictions in place? cloud.google.com/docs/authentication/…

– Andrew Harris
Mar 13 at 21:56













Are you using API v2 or v3?

– AwonDanag
Mar 14 at 4:10






Are you using API v2 or v3?

– AwonDanag
Mar 14 at 4:10













2 Answers
2






active

oldest

votes


















0














Solution



  • You can share


  • The folder of (xxxxx@gmail.com)


  • With (xxx@xxx.iam.gserviceaccount.com)


  • then the same code will work


Why




  • There are 2 users :



    • GClould service account (xxx@xxx.iam.gserviceaccount.com)


    • Google Drive account (xxxxx@gmail.com)



  • You can't use your GClould service account to access Google Drive App


How



enter image description here






share|improve this answer
































    0














    I had a similar issue and this worked for me:



    Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
    if (!file.MimeType.Equals("application/vnd.google-apps.spreadsheet"))

    //for files use another Url
    exportUrl = file.DownloadUrl;

    var response = service.HttpClient.GetByteArrayAsync(exportUrl).Result;
    Stream downloadStream = new MemoryStream(response);





    share|improve this answer








    New contributor




    ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.



















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056886%2fcannot-download-files-anymore%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Solution



      • You can share


      • The folder of (xxxxx@gmail.com)


      • With (xxx@xxx.iam.gserviceaccount.com)


      • then the same code will work


      Why




      • There are 2 users :



        • GClould service account (xxx@xxx.iam.gserviceaccount.com)


        • Google Drive account (xxxxx@gmail.com)



      • You can't use your GClould service account to access Google Drive App


      How



      enter image description here






      share|improve this answer





























        0














        Solution



        • You can share


        • The folder of (xxxxx@gmail.com)


        • With (xxx@xxx.iam.gserviceaccount.com)


        • then the same code will work


        Why




        • There are 2 users :



          • GClould service account (xxx@xxx.iam.gserviceaccount.com)


          • Google Drive account (xxxxx@gmail.com)



        • You can't use your GClould service account to access Google Drive App


        How



        enter image description here






        share|improve this answer



























          0












          0








          0







          Solution



          • You can share


          • The folder of (xxxxx@gmail.com)


          • With (xxx@xxx.iam.gserviceaccount.com)


          • then the same code will work


          Why




          • There are 2 users :



            • GClould service account (xxx@xxx.iam.gserviceaccount.com)


            • Google Drive account (xxxxx@gmail.com)



          • You can't use your GClould service account to access Google Drive App


          How



          enter image description here






          share|improve this answer















          Solution



          • You can share


          • The folder of (xxxxx@gmail.com)


          • With (xxx@xxx.iam.gserviceaccount.com)


          • then the same code will work


          Why




          • There are 2 users :



            • GClould service account (xxx@xxx.iam.gserviceaccount.com)


            • Google Drive account (xxxxx@gmail.com)



          • You can't use your GClould service account to access Google Drive App


          How



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 19 at 1:26

























          answered Mar 19 at 1:20









          Mohamed ElrashidMohamed Elrashid

          2,02511024




          2,02511024























              0














              I had a similar issue and this worked for me:



              Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
              if (!file.MimeType.Equals("application/vnd.google-apps.spreadsheet"))

              //for files use another Url
              exportUrl = file.DownloadUrl;

              var response = service.HttpClient.GetByteArrayAsync(exportUrl).Result;
              Stream downloadStream = new MemoryStream(response);





              share|improve this answer








              New contributor




              ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                I had a similar issue and this worked for me:



                Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
                if (!file.MimeType.Equals("application/vnd.google-apps.spreadsheet"))

                //for files use another Url
                exportUrl = file.DownloadUrl;

                var response = service.HttpClient.GetByteArrayAsync(exportUrl).Result;
                Stream downloadStream = new MemoryStream(response);





                share|improve this answer








                New contributor




                ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  I had a similar issue and this worked for me:



                  Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
                  if (!file.MimeType.Equals("application/vnd.google-apps.spreadsheet"))

                  //for files use another Url
                  exportUrl = file.DownloadUrl;

                  var response = service.HttpClient.GetByteArrayAsync(exportUrl).Result;
                  Stream downloadStream = new MemoryStream(response);





                  share|improve this answer








                  New contributor




                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  I had a similar issue and this worked for me:



                  Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
                  if (!file.MimeType.Equals("application/vnd.google-apps.spreadsheet"))

                  //for files use another Url
                  exportUrl = file.DownloadUrl;

                  var response = service.HttpClient.GetByteArrayAsync(exportUrl).Result;
                  Stream downloadStream = new MemoryStream(response);






                  share|improve this answer








                  New contributor




                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Mar 19 at 15:49









                  ChrisBChrisB

                  12




                  12




                  New contributor




                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  ChrisB is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056886%2fcannot-download-files-anymore%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme