我在应用程序中实现了 Google Picker API,其中包括 Google 云端硬盘 View 。目前,在 Google 云端硬盘 View 的搜索栏中输入搜索查询时,会开始显示一个下拉菜单,其中包含一些文件结果,如下所示:
但是,单击“放大镜”搜索按钮,或按 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/