访问公共共享文件时,是否有Google API隐藏用户详细信息(例如名称和个人资料图片)?

时间:2019-06-20 11:14:12

标签: google-drive-api google-api-client

我有一个用JavaScript编写并使用Google Drive API的程序,该程序允许编辑存储在Google Drive中的文件。
请考虑以下情形。
1.用户“ A”是文件的所有者,并将其存储在他/她的Google云端硬盘帐户中。 H(Sh)e公开共享了该文件。拥有该文件链接的任何人都可以对其进行编辑。
2.用户“ B”使用以下程序编辑此类文件。

允许用户登录的代码段。

function initAuth() {
  gapi.client.init({
    apiKey: API_KEY,
    discoveryDocs: DISCOVERY_DOCS
  }).then(function() {
    gapi.auth2.init({
      client_id: CLIENT_ID,
      fetch_basic_profile: false,
      scope: SCOPES
    }).then(function() {
      console.log('Successfully initialised client and auth');
      addListeners();
    }, function(error) {
      console.log(JSON.stringify(error, null, 2));
    });
  }, function(error) {
    console.log(JSON.stringify(error, null, 2));
  });
}

function handleAuthClick(event) {
  gapi.auth2.getAuthInstance().signIn();
}

function handleSignoutClick(event) {
  gapi.auth2.getAuthInstance().signOut();
}

function actionOnSignedIn() {
  if (isSignedIn) {
    var id = 'id-of-publicly-shared-file';
    var newTitle = 'test';
    renameFile(id, newTitle) {
  }
}

用于重命名文件的功能。

function renameFile(id, newTitle) {
  var request = gapi.client.drive.files.patch({
    'fileId':id,
    'resource': {
      'title': newTitle
    }
  });
  request.execute(function(file) {
    console.log('File is renamed to' + file.title);
  });
}

预期结果: 配置文件详细信息不应泄露给拥有文件的用户。但是,文件修改的时间戳应该更新。如果使用Google文档编辑了此类文件,则会发生这种情况。如何实现相同的行为?

实际结果: 拥有该文件的用户的Google云端硬盘帐户的“上次修改”标签中显示了个人资料详细信息,例如正在编辑公开共享文件的用户的名称和图像。请参考下图。drive-account-of-file-owner

0 个答案:

没有答案