从Cron-Python/Google-API运行不会接受存储的凭证文件,但会从命令行接受

从Cron-Python/Google-API运行不会接受存储的凭证文件,但会从命令行接受,python,cron,token,credentials,google-api-python-client,Python,Cron,Token,Credentials,Google Api Python Client,所以我有一个我认为可以运行的Python脚本,它可以访问存储的GoogleOAuth凭证文件 当我跑步时: source /METRICS/VIRTUALENVS/google/venv/bin/activate; export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client64/lib'; /METRICS/GOOGLESTATS/get_report_2.py 它的效果非常好 python中有一个块,用于检查存储文件中的凭据: #get googl

所以我有一个我认为可以运行的Python脚本,它可以访问存储的GoogleOAuth凭证文件

当我跑步时:

source /METRICS/VIRTUALENVS/google/venv/bin/activate; export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client64/lib'; /METRICS/GOOGLESTATS/get_report_2.py
它的效果非常好

python中有一个块,用于检查存储文件中的凭据:

#get google storage object
storage = Storage('cred_storage.txt')
credentials = storage.get()

#check if credentials are valid If not send to web page for new key.
if not credentials:
    flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
    authorize_url = flow.step1_get_authorize_url()
    print 'Go to the following link in your browser: ' + authorize_url
    code = raw_input('Enter verification code: ').strip()
    credentials = flow.step2_exchange(code)
    storage.put(credentials)
    mysendmail('Re authentication of credentials necessary')
    exit()
不过,如果我从本地用户crontab运行相同的操作,则凭据会失败,就像凭据文件无法读取一样

我不明白为什么从CRON运行命令与从命令行运行命令有区别

仅供参考,当凭据无法读取时,我会收到“转到URL”消息

我对凭据文件的权限是0755,所有者是本地crontab的用户


谢谢

好的,这是一个ID-10-T问题。 从命令行移动到cron时忘记设置工作目录


向前和向上

感谢@BostonMacOSX的帮助,这也是我的问题。