1

I studied and could successfully replicate the quickstart.py example on https://developers.google.com/drive/web/quickstart/quickstart-python to upload a file to my google drive using command line.

However, I wish to write an app that does the same, but through a cron job i.e. uploads a file everyday at 8am say, without the need to authenticate each time. Is there sample code/examples that I can look at to implement the oauth steps without the command line intervention?

Thanks!

elexhobby
  • 2,588
  • 5
  • 24
  • 33

2 Answers2

1

You can use your App Engine app's built-in Service Account to authorize requests to the Google Drive API.

Jason Hall
  • 20,632
  • 4
  • 50
  • 57
0

Your app will need to have an embedded Refresh Token, or some way of fetching it from a secure server. The Refresh Token acts a bit like a stored username/password, albeit with constrained access. Therefore you need to consider the security implications. For example, since it's uploading, it will only need drive.file scope, so your corpus of Drive files remain inaccessible.

If you're happy with the security implications, then the steps you need are described How do I authorise an app (web or installed) without user intervention? (canonical ?)

Community
  • 1
  • 1
pinoyyid
  • 21,499
  • 14
  • 64
  • 115