Google apps script Cronjob错误:无法找到客户端_secret.json文件Google应用程序脚本
我编写了一个python脚本,每天将一个文件上传到我的谷歌硬盘。当我从终端运行脚本时,它工作得非常好。但是,当通过cronjob运行时,它会失败并返回以下错误: oauth2client.clientsecrets.InvalidClientSecretError:('Error opening file','client_secret.json','No the file or directory',2) 问题是文件在我运行脚本的目录中 这是我的工作代码:Google apps script Cronjob错误:无法找到客户端_secret.json文件Google应用程序脚本,google-apps-script,Google Apps Script,我编写了一个python脚本,每天将一个文件上传到我的谷歌硬盘。当我从终端运行脚本时,它工作得非常好。但是,当通过cronjob运行时,它会失败并返回以下错误: oauth2client.clientsecrets.InvalidClientSecretError:('Error opening file','client_secret.json','No the file or directory',2) 问题是文件在我运行脚本的目录中 这是我的工作代码: 15 6 * * * python3
15 6 * * * python3 /home/pi/directory/file.py
以下是调用client_secret.json文件的脚本:
def main():
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None
SCOPES = 'https://www.googleapis.com/auth/drive.file'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store, flags) \
if flags else tools.run(flow, store)
DRIVE = build('drive', 'v3', http=creds.authorize(Http()))
任何想法或建议都会很好 必须使用文件client\u secret.json的绝对路径。一旦我更新了路径,一切都正常了 更改: flow=client.flow\u from\u clientsecrets('client\u secret.json',SCOPES) 及 store=file.Storage('Storage.json') 到 flow=client.flow\u from\u clientsecrets('/path/to/file/client\u secret.json',作用域) 及
store=file.Storage('/path/to/file/Storage.json')错误显示“打开文件时出错”、“client_secret.json”、“没有这样的文件或目录”。当它使用cron时,需要注意文件的路径。那么,如何更改client_secret.json文件的绝对路径呢?我不知道这是否能解决你的问题。对不起,我也试过了,但没用。对不起,我帮不了你。这是个好主意,糟糕透了,没用。谢谢你的检查。@Tanaike,实际上你是完全正确的。我在电脑上试过,但脚本在我的树莓皮上运行。你的问题让我重新思考,然后我意识到我没有更新我的树莓圆周率的脚本。一旦我做到了,一切都很顺利。谢谢你的帮助。