Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload to Google Drive without any UI?

I am looking to write a server application to upload files to Google Drive. I was previously using the Documents List API, but I see that is deprecated. I'd like to move to the Google Drive API, but that seems very restricted to using a web/OAuth flow.

All I need to do is upload Word, Excel files etc. to Google Drive, but I need to do this in an entirely automated manner, with no user interface of any kind. I wish to write a command line application, which can run on cron or whatever, and not require human intervention via the web etc.

I'd rather move away from Documents List API, as I don't want to get burned when they eventually turn it off, I'd like to use a supported API which Google are not going get rid of any time soon. Does this exist?

like image 455
Garry Avatar asked Sep 16 '12 11:09

Garry


People also ask

Can I upload directly to Google Drive?

You can upload files into private or shared folders. On your computer, go to drive.google.com. File Upload or Folder Upload. Choose the file or folder you want to upload.

Can I upload to Google Drive anonymously?

From the Run menu, choose doGet and authorize the script. The script needs these permissions since users will be uploading files to your Google Drive. Next choose Deploy as Web App from the Publish menu, choose Anyone, even Anonymous under who has access and then click the Deploy button.

Can Google Drive be used without app?

You can access Drive on the web by heading to drive.google.com or the free Android app. You can also view all your files via the Drive folder on your PC with Google Drive for Desktop, but you need to download the software first. You can get the software by visiting Drive's website.


1 Answers

Your application needs the user's permission to use the API against his files. That authorisation needs to happen using web based Oauth. The result of that authorisation is your server app ends up with a refresh token, which it can store. At any time, your app can convert that refresh token to an access token and access the drive files.

So, provided you accept that you need to do a one-time authorisation, you can achieve what you are looking for.

like image 70
pinoyyid Avatar answered Nov 25 '22 18:11

pinoyyid