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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With