Google Apps Script, OAuth requiring Login with Anonymous -


i'm trying pull revision history document own. when debug it, receive 401 error requiring login. however, i'm trying use anonymous consumerkey/consumersecret pass login , when debug it, urlfetch comes undefined. here's code have far:

//get revison history //fileid id of resource google docs function getrevisionhistory(fileid){  //scope var scope = 'https://www.googleapis.com/auth/drive';  //get google oauth arguments var fetchargs = googleoauth_('docs', scope);  //set fetch method fetchargs.method = 'list';  //feed url var url = 'https://www.googleapis.com/drive/v2/files/' + fileid + '/revisionsv=3&alt=json'; var urlfetch = urlfetchapp.fetch(url);  //get json of revision history entry var jsonfeed = utilities.jsonparse(urlfetch.getcontenttext()).feed.entry; //return revison history feed return jsonfeed }  //google oauth //used getrevisionhistory function googleoauth_(name, scope) {   var oauthconfig = urlfetchapp.addoauthservice(name);   oauthconfig.setaccesstokenurl("https://www.google.com/accounts/oauthgetaccesstoken");   oauthconfig.setrequesttokenurl("https://www.google.com/accounts/oauthgetrequesttoken?scope="+scope);   oauthconfig.setauthorizationurl("https://www.google.com/accounts/oauthauthorizetoken");   oauthconfig.setconsumerkey("anonymous");   oauthconfig.setconsumersecret("anonymous"); return {oauthservicename:name, oauthusetoken:"always"}; }  function trackchanges(jsonfeed){   var doc = documentapp.getactivedocument();   var docname = doc.getname();   var docid = doc.getid();    getrevisionhistory(docid)   var jsonstring = utilities.jsonstringify(jsonfeed);   var changes = documentapp.create("track changes " + docname);   var text = changes.getbody().editastext();   text.appendtext(jsonstring);    } 

any appreciated.

try adding api key (&key=mykey) urlfetch call drive api. can enable drive api , api key @ http://developer.google.com/console.

read more here - https://developers.google.com/console/help/#generatingdevkeys


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -