Reputation:
I have couple of Perl scripts that uploads / reads files from Google drive. Is it possible to access Google drive with Perl Api, or I need to switch to python or some scripting languages that Google supports.
Upvotes: 4
Views: 2735
Reputation: 840
You can download (not upload) without authentication using a link created by the "Share" button in Google Drive. When creating the link, click the "gear" icon in the share popup and change the option to "Viewers and commenters can see the option to download, print, and copy" (the other choice gives full edit permission, which you probably don't want). Then, back on the main "share" screen, select "Anyone with the link can access...".
The resulting URL will look like
https://docs.google.com/spreadsheets/d/<DOC_FILE_ID>/edit?usp=sharing
Extract the <DOC_FILE_ID> and use it like this to download the spreadsheet (format=pdf also works):
wget -O result.xlsx https://docs.google.com/spreadsheets/d/<DOC_FILE_ID>/export?format=xlsx
(or the equivalent using a Perl library)
There are other URL forms for non-spreadsheets, see https://www.howtogeek.com/747810/how-to-make-a-direct-download-link-for-google-drive-files/
I realize this does not answer the OP who wanted both upload & download; but for anyone who only needs read-only access to known Google docs, this is easy and avoids the Google authentication goop. Bear in mind, the DOC_FILE_ID gives anyone on the Internet read-only access, so be very careful if the doc is sensitive!
Upvotes: 0
Reputation: 1929
I just found a nice cpan module for talking to Google drive. So it might be as useful to you as it will be to me, because I just started playing with it. The only thing that is weird about it is that it needs to run install script to create the initial credentials on your machine.
Upvotes: 1
Reputation: 9213
We have a REST API. You can use any language to implement your own client, you don't have to use one of the client libraries we support.
Upvotes: 2