/* Get contents */ function getContentOfFile(theID){ //gets the content of the file current = theID; gapi.client.request({'path': '/drive/v2/files/'+theID,'method': 'GET',callback: function ( theResponseJS, theResponseTXT ) { var myToken = gapi.auth.getToken(); var myXHR = new XMLHttpRequest(); myXHR.open('GET', theResponseJS.downloadUrl, true ); myXHR.setRequestHeader('Authorization', 'Bearer ' + myToken.access_token ); myXHR.onreadystatechange = function( theProgressEvent ) { if (myXHR.readyState == 4) { if ( myXHR.status == 200 ) { var code = myXHR.response; } } } myXHR.send(); } }); }