可以公开使用Google Team Drive API吗?

时间:2018-10-11 13:39:41

标签: javascript google-drive-api google-drive-team-drive

我有一个显示用户收据的用户Web应用程序。该应用程序将搜索一个单击按钮,以打开Goog​​le云端硬盘并提取该收据并允许用户下载。

我遇到了用户的权限问题(因为我没有执行Google登录步骤?)

function start() {
    // Initializes the client with the API key and the Translate API.
    gapi.client.init({
        'apiKey': 'KEY HERE-xTr0',
        'clientId': 'CLIENT ID HERE',
        'discoveryDocs': ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'],
        'scope': "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.metadata https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/drive.photos.readonly https://www.googleapis.com/auth/drive.readonly"
        });
};
jQuery("#content").on('click','.reportopen', function(e){
    var data = jQuery(this).attr('data');
    return gapi.client.drive.files.list({
        "corpora": "user,allTeamDrives",
        "includeTeamDriveItems": true,
        "q": "name contains '"+ data +"' and mimeType != 'application/vnd.google-apps.folder'",
        "supportsTeamDrives": true
    }).then(function(response) {
        // Handle the results here (response.result has the parsed body).
        console.log("Response", response);
    },
    function(err) { console.error("Execute error", err); });
});

// Loads the JavaScript client library and invokes `start` afterwards.
gapi.load('client', start);

错误

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientFilePermissions",
    "message": "The user does not have sufficient permissions for this file."
   }
  ],
  "code": 403,
  "message": "The user does not have sufficient permissions for this file."
 }
}

0 个答案:

没有答案