我正在使用 Drive Picker Api并在网页中制作驱动器选择器。我只显示用户拥有的驱动器文件或项目(相当于使用 query as owner="me"
)。
现在我在选择器中遇到了一个问题:它还显示了用户不是所指向文件的所有者的文件或项目的快捷方式。
我需要显示用户拥有的文件。要么用一种方法来归档所有快捷方式,要么理想情况下只提供用户是所有者的文件或项目的快捷方式。
这是所有者文件选择器的示例代码。
//The API developer key obtained from the Google Cloud Console.
var developerKey = "{developerkey value}";
// The Client ID obtained from the Google Cloud Console.
var clientId = "{clientId value}";
// Scope to use to access user's Drive.
var scope = [
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/userinfo.email",
];
var pickerApiLoaded = false;
var oauthToken;
// Use the API Loader script to load google.picker and gapi.auth
function onApiLoad() {
gapi.load("auth", { callback: onAuthApiLoad });
gapi.load("picker", { callback: onPickerApiLoad });
}
function onAuthApiLoad() {
window.gapi.auth.authorize(
{
client_id: clientId,
scope: scope,
immediate: false,
},
handleAuthResult
);
}
function onPickerApiLoad() {
pickerApiLoaded = true;
createPicker();
}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
oauthToken = authResult.access_token;
createPicker();
}
}
// Create and render a Picker object.
function createPicker() {
var DocsView = new google.picker.DocsView(
google.picker.ViewId.DOCS
).setOwnedByMe(true);
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_DRIVES)
.addView(DocsView)
.addView(new google.picker.DocsUploadView())
.setDeveloperKey(developerKey)
.setOAuthToken(oauthToken)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);
}
你能帮助我吗?如何在选取器中排除快捷方式或显示用户为其所有者的快捷方式。