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

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page