How to download Google Apps Script?

5.1k views Asked by At

I'm currently writing a little Ruby script to sync my Google Apps Script files. I'm mainly following the instructions from the Google Developers and the examples on Github (google/google-api-ruby-client-samples).

After getting the list of project files I'm trying to get the content of each file. Like proposed in the guide I fetch the the export-links URL:

result = google_client.execute(:uri => file_data['exportLinks']['application/vnd.google-apps.script+json'])

The problem now is that I get the HTTP status 302 and HTML content telling me that the document has moved. Opening the URL in my browser downloads the file correctly. My guess would be that this is due to some authentication functionality. Is there any way to make the client library handle this properly?

Fetching a normal document in any format works fine this way...

The complete code can be found on GitHub: https://github.com/Devex/gaspm

1

There are 1 answers

2
Burcu Dogan On

You can GET https://script.google.com/feeds/download/export?format=json&id=[fileId] with the same access token you use to authorize other Drive API requests.