Error when trying to get Google Drive File

2019-07-25 17:18发布

I am getting an error when trying to get a Google Drive File using:

file = service.files().get(fileId=<googleDriveFileId>).execute()

The error is:

<HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc?alt=json returned "File not found: 0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc">

However, when I copy and paste that link directly in the browser like this: https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc?alt=json

I get a different error:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit Exceeded. Please sign up",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit Exceeded. Please sign up"
 }
}

I am no where even close to exceeding the daily limit, the console shows 0% usage. I know the fileId is correct, I am using Google Picker to get the fileId. Any ideas?

1条回答
Luminary・发光体
2楼-- · 2019-07-25 17:48

I have found elsewhere that this is known issue with Google Drive that they are working to resolve. They offer the following workaround that I have confirmed works.

Add the following to when building the picker:

enableFeature(google.picker.Feature.MULTISELECT_ENABLED).

complete code:

var picker = new google.picker.PickerBuilder().
        addView(view).
        addView(uploadView).
        setAppId("pressomatic").
        setCallback(pickerCallback).
        enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
        build();
    picker.setVisible(true);

This same workaround solves another problem I have posted about, when trying to upload to a specific folder with Google Picker using setParent on a DocsUploadView. You still add the same feature to the Picker, not the DocsUploadView, and everything works as it should.

查看更多
登录 后发表回答