google-drive-api

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?


Solution

  • 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.