google-drive-api - 在 Google Drive Picker 中使用搜索栏不会显示任何结果,并会在网络响应中引发内部错误

标签 google-drive-api google-picker

我在应用程序中实现了 Google Picker API,其中包括 Google 云端硬盘 View 。目前,在 Google 云端硬盘 View 的搜索栏中输入搜索查询时,会开始显示一个下拉菜单,其中包含一些文件结果,如下所示:

search bar drop down

但是,单击“放大镜”搜索按钮,或按 Enter 键,或单击“搜索包含...的所有项目”,所有结果都会出现一个空选择器,如下所示:

empty picker with no search results

我相信发生这种情况是因为对 https://docs.google.com/picker/pvr 的调用每次都会返回此错误作为响应:&&&START&&&{"error":true,"errorMessage":"内部错误"}.

发送到/pvr 端点的参数位于此处:

start: 0
numResults: 50
sort: 3
desc: true
q: testing
cursor: 
mine: 2
service: docs
type: NOT_COLLECTION
options: {"ff":true,"filterTeamDriveResults":true}
token: J********
version: 4
app: 2
clientUser: 1************
developerKey: A*************
subapp: 5

我发现,从“options”哈希中手动删除 "filterTeamDriveResults":true 键并执行 ajax post 直接导致请求成功,但无论出于何种原因包含该选项对于来自选择器的每个请求,以及每当包含该选项的请求发出时,它似乎都会失败并出现相同的“内部错误”响应。我想知道该选项的来源是什么,以及是否有任何方法可以将其从我们的选择器中删除。据我所知,它似乎不受我们从 https://apis.google.com/js/api.js?onload=onApiLoad 加载的 JavaScript API 中的任何选项控制。 .

最佳答案

我们在使用 Google Picker API 多年且未出现任何问题后,上周也开始出现这种情况。您关于 filterTeamDriveResults 键的线索让我想起了我刚刚读过的关于 upcoming changes to the Google Drive API and Google Picker API 的内容。 :

Next, we’re introducing a new Drive API resource collection, called “Drives,” to replace the “Team Drives” resource collection. This new resource collection can help you create, delete, get, list and update your shared drives, and features all the same fields, resources and available methods as the “Team Drives” resource collection. If you have been using the “Team Drives” resource collection in your applications, consider migrating as soon as possible as all related fields for Drive API , Drive Activity API and Google Picker API, will no longer be supported starting June 1, 2020.

它似乎不相关,至少不直接相关,但让我觉得也许,the SUPPORT_DRIVES feature我在文档中看到过,可以“禁用”其他 teamDrive 功能(尽管事实并非如此,但仍然......)。事实上,这解决了问题。基本上只是:

new google.picker.PickerBuilder().
  setAppId(appId).
  addView(new google.picker.DocsView().setIncludeFolders(true)).
  enableFeature(google.picker.Feature.SUPPORT_DRIVES)
...

需要注意的一件事是启用此功能时出现的警告:

Before enabling this make sure to refer to Google Drive API documentation for enabling shared drives and make any necessary Drive Rest API changes.

可能与您的情况相关。

关于google-drive-api - 在 Google Drive Picker 中使用搜索栏不会显示任何结果,并会在网络响应中引发内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57559410/

相关文章:

google-apps-script - 如何解析存储在我的谷歌驱动器中但作为 html 类型突出的 XML 文件?

google-drive-api - anchor 文档不存在?

android - 如何在电子表格中获取应用程序脚本的 ID

swift - 如何在 Google Place AutocompleteViewController 的 GMSAutocompleteViewController 中设置文本

javascript - 如何从 Google Picker API 获取多张选中的图片

google-drive-api - 如何复制 Google 云端硬盘文件夹并删除 Google 云端硬盘关联?

javascript - 如何在 Google 云端硬盘选择器上显示文件夹而不显示私有(private)文件?

javascript - Angular 6 - Google Picker API 弹出窗口

google-picker - Google Picker - Alert - 您将要向 localhost 发送 1 个项目。你想继续吗?

javascript - 无法使用 Google App 脚本打开 FilePicker