反正有没有获得drive.file范围的用户的私人文件 [英] Is there anyway to get private file of user with drive.file scope

查看:39
本文介绍了反正有没有获得drive.file范围的用户的私人文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取不是由我的具有访问令牌的应用程序创建的用户(元数据,内容,downloadUrl)的驱动器文件只有drive.file范围.有人可以为此解决方案吗?谢谢.

I want to get drive file of user (metadata, content, downloadUrl) not created by my application with access token have only drive.file scope. Can anyone have a solution for this one? Thank you.

 gapi.client.load('drive', 'v3', () => {
  gapi.auth.setToken({
    access_token: user.services.google.accessToken,
    expires_in: user.services.google.expiresAt,
  });
  gapi.client.drive.files.get({
    fileId: file.id,
    fields: 'webContentLink',
  }).then( test => {
    console.log('test', test);
  })
});

推荐答案

您需要访问用户文件才能获取webContentLink

您可以在脚本中包含一个功能,该功能允许用户与您共享文件,例如:

You need to have access to user's file in order to obtain the webContentLink

You can incorporate in your script a function that allows the user to share his file with you, something like:

drive.permissions.create({
    resource: {
        'type': 'user',
        'role': 'reader',
        'emailAddress': 'YOUR EMAIL'
    }, 
        fileId: file.id,
    }
...);

这篇关于反正有没有获得drive.file范围的用户的私人文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆