最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

security - Minimal Google Drive scope to select folder and move files there - Stack Overflow

programmeradmin0浏览0评论

I am writing a Google Workspace add-on where the script creates one Google Document for each line in a Google Sheet owned by the user. The Google Documents are saved in the root of the user's Google Drive. I want the script to be able to automatically move all the files to a folder chosen by the user (or to create the files directly in a specified folder). I don't want the script to access the other user's files.

This only works if I add the scope, whereas .file is enough to create the new files in the root folder.

Is there a way to do what I want without using ?

I am writing a Google Workspace add-on where the script creates one Google Document for each line in a Google Sheet owned by the user. The Google Documents are saved in the root of the user's Google Drive. I want the script to be able to automatically move all the files to a folder chosen by the user (or to create the files directly in a specified folder). I don't want the script to access the other user's files.

This only works if I add the https://www.googleapis/auth/drive scope, whereas https://www.googleapis/auth/drive.file is enough to create the new files in the root folder.

Is there a way to do what I want without using https://www.googleapis/auth/drive?

Share Improve this question edited Feb 4 at 0:26 TheMaster 50.9k7 gold badges69 silver badges99 bronze badges asked Feb 1 at 16:47 François TalbotFrançois Talbot 114 bronze badges 2
  • Looks like moveTo(destination) requires the scope that ends in drive – Cooper Commented Feb 1 at 18:36
  • I was hoping to find a way to write to Drive (or move files created by the script) without being able to read other files, to ensure the privacy of the user. – François Talbot Commented Feb 1 at 20:59
Add a comment  | 

1 Answer 1

Reset to default 3

You may be able do this with google-picker and making user choose the folder they want, using scope:

https://www.googleapis/auth/drive.file

See https://developers.google/apps-script/guides/dialogs#file-open_dialogs

Alternatively, You may try creating the folder yourself and then try moving the file there using inbuilt methods or if inbuilt methods throw an error, then by accessing the respective apis.

发布评论

评论列表(0)

  1. 暂无评论