download Google Drive files through Google Drive API












0















I have make the server account authentication through the python code:



APP_CREDENTIALS = service_account.Credentials.from_service_account_file(
#config.EE_ACCOUNT,
config.EE_PRIVATE_KEY_FILE,
scopes = OAUTH_SCOPE)

service = build('drive', 'v3', credentials=APP_CREDENTIALS)


And I typed this code to print those files in drive:



state = task.status()['state']
if state == ee.batch.Task.State.COMPLETED:
logging.info('Task succeeded (id: %s).', task.id)

results = service.files().list().execute()
items = results.get('files', )
if not items:
print('No files found.')
else:
print('Files:')
for item in items:
if item['id'] == '1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF':
print('downloadfiles')
download_file(item['id'], service)
print(u'{0} ({1})'.format(item['name'], item['id']))


The result was:



NDVI_1229.tif (1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF)
NDVI_1229.tif (1y5anN0zpRYW180pd0t74xbOWxr0bjfdm)
NDVI_1229.tif (1X8fYAzRrUBxPMLpZmx_bJULLwq09lJPb)
NDVI_1229.tif (1iSk51dCTAyiVjPbCFQ3irnjhYsn708mV)
NDVI_1229.tif (1Cr3G7tZF2xYAmO70n6tvSs65Ot7MWr69)
NDVI_1229.tif (1KlGUVmr3maaiya4WAeD0ShI6DAsUcxT5)
NDVI_1229.tif (1kkGxRQulWYIG7tX0J8f_n5T1hwhYK_O0)
NDVI_1229.tif (1AqgchB8X7aul1rhVk76GlF1Iwm5N-UFR)
NDVI_1229.tif (14A7Kzcweaft8eBof_nWQGtLQ5RwvpFlP)
NDVI.tif (1GvY3JlMmqE-TgvqR5Fg8zPa9JvuJAyHJ)
NDVI.tif (15N4Kge7gR5bk7B3ZwRBG4Tad0PKU9nPc)
NDVI.tif (19cr8Ena_oztorgmOQL-FTBvNq4vN7nD9)
NDVI.tif (1oK5N5GTiTthkpk6rtjFF9wM4qeXDtESR)


Now I want to download those files, and I use the method given in the Google Drive API official website. The code was shown below:



def download_file(file_id, drive_service):
request = drive_service.files().get_media(fileId=file_id)
fh = io.BytesIO()
downloader = http.MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print "Download %d%%." % int(status.progress() * 100)
return fh.getvalue()


And I got this answer:



INFO     2019-01-02 08:32:04,585 discovery.py:871] URL being requested: GET https://www.googleapis.com/drive/v3/files/1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF?alt=media
Download 100%.


I opened the link, its content was like this:



{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}


So I am confused that whether my authentication method is correct or not.
And I have tried different ways to download files from this drive or export this drive's files to other user's drive, it has the same answer.










share|improve this question





























    0















    I have make the server account authentication through the python code:



    APP_CREDENTIALS = service_account.Credentials.from_service_account_file(
    #config.EE_ACCOUNT,
    config.EE_PRIVATE_KEY_FILE,
    scopes = OAUTH_SCOPE)

    service = build('drive', 'v3', credentials=APP_CREDENTIALS)


    And I typed this code to print those files in drive:



    state = task.status()['state']
    if state == ee.batch.Task.State.COMPLETED:
    logging.info('Task succeeded (id: %s).', task.id)

    results = service.files().list().execute()
    items = results.get('files', )
    if not items:
    print('No files found.')
    else:
    print('Files:')
    for item in items:
    if item['id'] == '1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF':
    print('downloadfiles')
    download_file(item['id'], service)
    print(u'{0} ({1})'.format(item['name'], item['id']))


    The result was:



    NDVI_1229.tif (1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF)
    NDVI_1229.tif (1y5anN0zpRYW180pd0t74xbOWxr0bjfdm)
    NDVI_1229.tif (1X8fYAzRrUBxPMLpZmx_bJULLwq09lJPb)
    NDVI_1229.tif (1iSk51dCTAyiVjPbCFQ3irnjhYsn708mV)
    NDVI_1229.tif (1Cr3G7tZF2xYAmO70n6tvSs65Ot7MWr69)
    NDVI_1229.tif (1KlGUVmr3maaiya4WAeD0ShI6DAsUcxT5)
    NDVI_1229.tif (1kkGxRQulWYIG7tX0J8f_n5T1hwhYK_O0)
    NDVI_1229.tif (1AqgchB8X7aul1rhVk76GlF1Iwm5N-UFR)
    NDVI_1229.tif (14A7Kzcweaft8eBof_nWQGtLQ5RwvpFlP)
    NDVI.tif (1GvY3JlMmqE-TgvqR5Fg8zPa9JvuJAyHJ)
    NDVI.tif (15N4Kge7gR5bk7B3ZwRBG4Tad0PKU9nPc)
    NDVI.tif (19cr8Ena_oztorgmOQL-FTBvNq4vN7nD9)
    NDVI.tif (1oK5N5GTiTthkpk6rtjFF9wM4qeXDtESR)


    Now I want to download those files, and I use the method given in the Google Drive API official website. The code was shown below:



    def download_file(file_id, drive_service):
    request = drive_service.files().get_media(fileId=file_id)
    fh = io.BytesIO()
    downloader = http.MediaIoBaseDownload(fh, request)
    done = False
    while done is False:
    status, done = downloader.next_chunk()
    print "Download %d%%." % int(status.progress() * 100)
    return fh.getvalue()


    And I got this answer:



    INFO     2019-01-02 08:32:04,585 discovery.py:871] URL being requested: GET https://www.googleapis.com/drive/v3/files/1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF?alt=media
    Download 100%.


    I opened the link, its content was like this:



    {
    "error": {
    "errors": [
    {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
    }
    ],
    "code": 403,
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
    }
    }


    So I am confused that whether my authentication method is correct or not.
    And I have tried different ways to download files from this drive or export this drive's files to other user's drive, it has the same answer.










    share|improve this question



























      0












      0








      0








      I have make the server account authentication through the python code:



      APP_CREDENTIALS = service_account.Credentials.from_service_account_file(
      #config.EE_ACCOUNT,
      config.EE_PRIVATE_KEY_FILE,
      scopes = OAUTH_SCOPE)

      service = build('drive', 'v3', credentials=APP_CREDENTIALS)


      And I typed this code to print those files in drive:



      state = task.status()['state']
      if state == ee.batch.Task.State.COMPLETED:
      logging.info('Task succeeded (id: %s).', task.id)

      results = service.files().list().execute()
      items = results.get('files', )
      if not items:
      print('No files found.')
      else:
      print('Files:')
      for item in items:
      if item['id'] == '1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF':
      print('downloadfiles')
      download_file(item['id'], service)
      print(u'{0} ({1})'.format(item['name'], item['id']))


      The result was:



      NDVI_1229.tif (1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF)
      NDVI_1229.tif (1y5anN0zpRYW180pd0t74xbOWxr0bjfdm)
      NDVI_1229.tif (1X8fYAzRrUBxPMLpZmx_bJULLwq09lJPb)
      NDVI_1229.tif (1iSk51dCTAyiVjPbCFQ3irnjhYsn708mV)
      NDVI_1229.tif (1Cr3G7tZF2xYAmO70n6tvSs65Ot7MWr69)
      NDVI_1229.tif (1KlGUVmr3maaiya4WAeD0ShI6DAsUcxT5)
      NDVI_1229.tif (1kkGxRQulWYIG7tX0J8f_n5T1hwhYK_O0)
      NDVI_1229.tif (1AqgchB8X7aul1rhVk76GlF1Iwm5N-UFR)
      NDVI_1229.tif (14A7Kzcweaft8eBof_nWQGtLQ5RwvpFlP)
      NDVI.tif (1GvY3JlMmqE-TgvqR5Fg8zPa9JvuJAyHJ)
      NDVI.tif (15N4Kge7gR5bk7B3ZwRBG4Tad0PKU9nPc)
      NDVI.tif (19cr8Ena_oztorgmOQL-FTBvNq4vN7nD9)
      NDVI.tif (1oK5N5GTiTthkpk6rtjFF9wM4qeXDtESR)


      Now I want to download those files, and I use the method given in the Google Drive API official website. The code was shown below:



      def download_file(file_id, drive_service):
      request = drive_service.files().get_media(fileId=file_id)
      fh = io.BytesIO()
      downloader = http.MediaIoBaseDownload(fh, request)
      done = False
      while done is False:
      status, done = downloader.next_chunk()
      print "Download %d%%." % int(status.progress() * 100)
      return fh.getvalue()


      And I got this answer:



      INFO     2019-01-02 08:32:04,585 discovery.py:871] URL being requested: GET https://www.googleapis.com/drive/v3/files/1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF?alt=media
      Download 100%.


      I opened the link, its content was like this:



      {
      "error": {
      "errors": [
      {
      "domain": "usageLimits",
      "reason": "dailyLimitExceededUnreg",
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
      "extendedHelp": "https://code.google.com/apis/console"
      }
      ],
      "code": 403,
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
      }
      }


      So I am confused that whether my authentication method is correct or not.
      And I have tried different ways to download files from this drive or export this drive's files to other user's drive, it has the same answer.










      share|improve this question
















      I have make the server account authentication through the python code:



      APP_CREDENTIALS = service_account.Credentials.from_service_account_file(
      #config.EE_ACCOUNT,
      config.EE_PRIVATE_KEY_FILE,
      scopes = OAUTH_SCOPE)

      service = build('drive', 'v3', credentials=APP_CREDENTIALS)


      And I typed this code to print those files in drive:



      state = task.status()['state']
      if state == ee.batch.Task.State.COMPLETED:
      logging.info('Task succeeded (id: %s).', task.id)

      results = service.files().list().execute()
      items = results.get('files', )
      if not items:
      print('No files found.')
      else:
      print('Files:')
      for item in items:
      if item['id'] == '1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF':
      print('downloadfiles')
      download_file(item['id'], service)
      print(u'{0} ({1})'.format(item['name'], item['id']))


      The result was:



      NDVI_1229.tif (1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF)
      NDVI_1229.tif (1y5anN0zpRYW180pd0t74xbOWxr0bjfdm)
      NDVI_1229.tif (1X8fYAzRrUBxPMLpZmx_bJULLwq09lJPb)
      NDVI_1229.tif (1iSk51dCTAyiVjPbCFQ3irnjhYsn708mV)
      NDVI_1229.tif (1Cr3G7tZF2xYAmO70n6tvSs65Ot7MWr69)
      NDVI_1229.tif (1KlGUVmr3maaiya4WAeD0ShI6DAsUcxT5)
      NDVI_1229.tif (1kkGxRQulWYIG7tX0J8f_n5T1hwhYK_O0)
      NDVI_1229.tif (1AqgchB8X7aul1rhVk76GlF1Iwm5N-UFR)
      NDVI_1229.tif (14A7Kzcweaft8eBof_nWQGtLQ5RwvpFlP)
      NDVI.tif (1GvY3JlMmqE-TgvqR5Fg8zPa9JvuJAyHJ)
      NDVI.tif (15N4Kge7gR5bk7B3ZwRBG4Tad0PKU9nPc)
      NDVI.tif (19cr8Ena_oztorgmOQL-FTBvNq4vN7nD9)
      NDVI.tif (1oK5N5GTiTthkpk6rtjFF9wM4qeXDtESR)


      Now I want to download those files, and I use the method given in the Google Drive API official website. The code was shown below:



      def download_file(file_id, drive_service):
      request = drive_service.files().get_media(fileId=file_id)
      fh = io.BytesIO()
      downloader = http.MediaIoBaseDownload(fh, request)
      done = False
      while done is False:
      status, done = downloader.next_chunk()
      print "Download %d%%." % int(status.progress() * 100)
      return fh.getvalue()


      And I got this answer:



      INFO     2019-01-02 08:32:04,585 discovery.py:871] URL being requested: GET https://www.googleapis.com/drive/v3/files/1MiXjaHXU3ktOrkVwdkAABuNM-HXhJGGF?alt=media
      Download 100%.


      I opened the link, its content was like this:



      {
      "error": {
      "errors": [
      {
      "domain": "usageLimits",
      "reason": "dailyLimitExceededUnreg",
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
      "extendedHelp": "https://code.google.com/apis/console"
      }
      ],
      "code": 403,
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
      }
      }


      So I am confused that whether my authentication method is correct or not.
      And I have tried different ways to download files from this drive or export this drive's files to other user's drive, it has the same answer.







      google-drive-sdk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 4 at 1:10









      rilla

      342114




      342114










      asked Jan 3 at 1:09









      zi yangzi yang

      11




      11
























          0






          active

          oldest

          votes












          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%2f54015143%2fdownload-google-drive-files-through-google-drive-api%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f54015143%2fdownload-google-drive-files-through-google-drive-api%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

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith