Here is the complete solution:
1) Create an empty script on your disk
2) Paste the following code:
function doGet() { try{ authorize(); var key = "YOUR DEVELOPER KEY"; var params = {method:"DELETE", oAuthServiceName: "drive", oAuthUseToken: "always" }; UrlFetchApp.fetch("https://www.googleapis.com/drive/v2/files/trash?key="+key, params); } catch(error) { MailApp.sendEmail("<some email>", "EMPTY TRASH BIN ERROR:<br>"+error); return; } } function authorize() { var oauthConfig = UrlFetchApp.addOAuthService("drive"); var scope = "https://www.googleapis.com/auth/drive"; oauthConfig.setConsumerKey("anonymous"); oauthConfig.setConsumerSecret("anonymous"); oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken? scope="+scope); oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken"); oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); }
3) Deploy the script as a web application
4) Click the clock on the top panel and create a trigger that calls the doGet method
This will empty the trash for the user creating the trigger.
user3706099
source share