I have this python code snippet to upload file to google drive.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os
g_login = GoogleAuth()
g_login.LocalWebserverAuth()
drive = GoogleDrive(g_login)
with open("test_gdrive.csv",'r',encoding = 'unicode_escape') as file:
file_drive = drive.CreateFile({"mimeType": "text/csv" })
file_drive.SetContentString(file.read())
file_drive.Upload({'convert': True})
It is working completely fine. Now i want to automate this with a cronjob written on a linux server.When i run this on the server, it is asking for local browser authentication and could not proceed further. How can i write a cronjob in server to upload the file to gdrive everyday? Is it possible ? I have read at places that it violates google policies and cant be done. If that is the case,is there any other way ?