我已按照https://pythonhosted.org/PyDrive/quickstart.html成功地将文件上传到了Google驱动器, https://pythonhosted.org/PyDrive/oauth.html#automatic-and-custom-authentication-with-settings-yaml
但是,cron作业无法通过执行同一文件将文件上传到Google驱动器。
这是我的设置
下载client_secrets.json
quickstart.py
from my drive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.CommandLineAuth() # gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
.
.
def create_csv()
.
.
def upload()
.
.
settings.yaml
client_config_backend: settings
client_config:
client_id: ***
client_secret: ***
save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json
get_refresh_token: True
oauth_scope:
- https://www.googleapis.com/auth/drive.file
- https://www.googleapis.com/auth/drive.install
为什么Cron工作不起作用?是因为OAuth吗?
谢谢
答案 0 :(得分:0)
您可能想尝试:
从原始存储库https://github.com/klanjabrik/Backup-To-Google-Drive(Python 2)中派生https://github.com/bachvtuan/Backup-To-Google-Drive(Python 3)