PDA

Ver la versión completa : [Ayuda] con script de aplicación web para google drive.



Dullyboy
16/01/2015, 14:29
¿Sabe alguien porque no me funciona este script para google drive? Es para vaciar automáticamente la papelera.

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");

Lo saqué de aquí (http://stackoverflow.com/questions/11960526/google-drive-how-to-empty-trash-from-code-programmatically) pero me da error de autorización.
Gracias por adelantado.