Student Gradebook. Unable to complete script because of “Access denied: DriveApp”

前端 未结 3 1963
无人共我
无人共我 2021-01-15 18:30

My script takes 35 student names from the Sheet \'Studenti\'. Then finds the proper folder with their name (i.e. \'Smith Peter\'), removes old pdf document with old grades h

相关标签:
3条回答
  • 2021-01-15 19:01

    In the SO post, the user is trying to delete the converted file and got the same error as you are.

    I suspect you're hitting a rate limit. If you are doing more than 20 write operations (create, update, delete) in rapid succession, you need to throttle the requests to approximately one every 1.5 seconds.

    Suspected reason is the user hits rate limit. Since you are also updating a data, there is also a possibility that this is the reason why it is working on the first few execution and reached the limit after.

    And that is the only allotted maximum throughput you can achieve in Drive.

    0 讨论(0)
  • 2021-01-15 19:13

    After few experiments I found the roots of the problem but not the solution. The problem with "Access denied" was related to the fact, that I was not the owner of the file created by my script and only the owner of the file may trash or delete the file. Although I was author of the script and had edit rights to the file which was placed on my drive, it did not work. On the other hand I could delete/trash the file manually without problems (and it was misleading for me).

    Lesson learnt: If you allow someone else to use your script that creates a new file and also trashes the old one than you probably cannot complete your script next time sice you are not allowed (Access denied) to trash the file created by other user (although the file was created on your own drive !).

    Adjusted question: Does anybody know how to write the script to trash/delete the file of which I am not the owner ( but I have edit rights) and which was created by other user on my drive?

    0 讨论(0)
  • 2021-01-15 19:14

    I have the same problem with trashing files, that I don't own. I found that

    1. If you are on the list getEditors() or getViewers() I have the solution: Just revoke permission from yourself. file.revokePermissions(Session.getActiveUser()); and file will disappear.
    2. Example 1 doesn't work if file has set isShareableByEditors() - if it's "false", then you can't do anything.
    3. If you've added file to your drive which is publicly accessible for everyone with link, you can't revoke permissions, because you don't have one. app script return access denied. So, I thought that I can setTrashed(true). I was wrong. Google also return Access denied: DriveAp.

    I didn't find a way to remove unwanted files from my drive in case 2 and 3 thru apps script. But it's still possible by clicking on them and choosing option "Remove".

    0 讨论(0)
提交回复
热议问题