问题描述
通过调用七牛云python sdk下载cdn日志文件一直报错报错401
问题出现的平台版本及自己尝试过哪些方法
mac
python2.7
qiniu==7.2.2
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
import qiniu
from qiniu import CdnManager
import requests
access_key = 'access_key'
secret_key = 'secret_key'
auth = qiniu.Auth(access_key=access_key, secret_key=secret_key)
cdn_manager = CdnManager(auth)
log_date = '2017-07-17'
urls = [
'urls'
]
ret, info = cdn_manager.get_log_list_data(urls, log_date)
for i in ret['data']['urls']:
r = requests.get(i['url'])
print r.json()
你期待的结果是什么?实际看到的错误信息又是什么?
错误结果:
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'Document not found'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'token out of date'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
{u'error': u'Document not found'}
这个错误表示token过期了
检查下时间戳;本地时间要和服务端一直 GMT+8