I am using Pydrive
module for uploading files to my google drive. The code which I am using:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
file1 = drive.CreateFile({'title': 'hello.txt'})
file1.SetContentString('Hello world project')
file1.Upload()
When I run this code, browser opens and I need to click on the google account for sign in. This process repeats everytime I run the code. Is there a way where on running the code, the file uploads automatically? like providing google email account and password in the code.
Originally answered in this Question
To automatically Upload Files to Google Drive via PyDrive module use this code template