title: Google Drive - How to empty trash from Google API
body: <p>I searched and found this solution <a href="https://stackoverflow.com/questions/11960526/google-drive-how-to-empty-trash-from-code-programmatically">here</a>:</p>
  
  <pre><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("&lt;some email&gt;", "EMPTY TRASH BIN ERROR:&lt;br&gt;"+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");  
  </code></pre>
  
  <p>I "fixed"</p>
  
  <pre><code>MailApp.sendEmail("&lt;some email&gt;", "EMPTY TRASH BIN ERROR:&lt;br&gt;", error);
  </code></pre>
  
  <p>to get errors in my mail, and put my developer key (some like this ZHjkMQP3dNiA24LmOvZ5WZ2v-_-APMcbEtHD6q) in var key but yet I get authoritation error:</p>
  
  <p>Exception: Error OAuth:</p>