External JS from Google Drive

637 views
Skip to first unread message

Rodrigo Munoz

unread,
Oct 3, 2013, 7:25:38 AM10/3/13
to adwords...@googlegroups.com

Hi

I frequently use Google drive to store some .js files an access by:


function main() {
  var url = "https://googledrive.com/host/#############";
  eval(UrlFetchApp.fetch(url).getContentText());
...

On ######## you can put your ID, the referenced field should be a Public, otherwise get an error.

Now I have some code with confidential information, and I can´t share the file as Public, should be accessible from me, or at least people on my domain.

I´m not capable of made it work, I have always the same error on Adwords Scripts console:

Request failed for
https://googledrive.com/host/######## returned code 404. Truncated server
response: <!DOCTYPE html><html lang=en><meta
charset=utf-8><title>Error 404 (Not
Found)!!1</title><style>*{margin:0;padding:0}html,code{font:15px/22px
arial,... (use muteHttpExceptions option to examine full response)
muteHttpExceptions option to examine full response)

I really need some help.  L

Alexander Wang

unread,
Oct 3, 2013, 1:45:45 PM10/3/13
to adwords...@googlegroups.com
Hi Rodrigo,

Perhaps instead of using UrlFetchApp to fetch the file you can use DriveApp? You wouldn't need to make the file publicly fetchable via UrlFetch and could make it private to yourself (or explicitly share it with other people).

In your AdWords Script you could do something like:
var code = DriveApp.getFileById(FILE_ID).getBlob().getDataAsString();
eval(code);

Cheers,
Alex

Russell Savage

unread,
Oct 9, 2013, 3:52:24 AM10/9/13
to adwords...@googlegroups.com
Hi Rodrigo, My blog post provides an example of how to load .js files from Google Drive.  I hope it helps! http://savageautomation.com/use-gdrive-to-load-a-single-adwords-script-into-multiple-accounts/

Thanks,
Russ
Reply all
Reply to author
Forward
0 new messages