这篇文章是How to do OAuth-requiring operations in a GAE Task Queue?的后续内容.正如bossylobster在这篇文章中所建议的,我确实尝试在我的脚本中硬编码user_id,但是cron任务总是失败:
>我可以看到它在日志中被触发……
2013-05-31 14:20:00.879 /update 302 5ms 0kb AppEngine-Google; (+http://code.google.com/appengine)
0.1.0.1 - - [31/May/2013:11:20:00 -0700] "GET /update HTTP/1.1" 302 385 - "AppEngine-Google; (+http://code.google.com/appengine)" "myapp.appspot.com" ms=6 cpu_ms=0 cpm_usd=0.000043 queue_name=__cron task_name=... app_engine_release=1.8.0 instance=...
> …但是,它总是失败(在AppEngine的Cron Jobs部分显示为红色“失败”),它应该运行的任务队列永远不会弹出任务队列部分.
我不明白的是,如果我手动打开/更新,我在下面有登录提示. cron如何绕过那个?我该如何调试正在进行的操作?
谢谢您的帮助.
对@dlebech进行编辑/跟进回答:在app.yaml中添加登录后,问题仍然存在:admin行到相关网址.在本地(通过以管理员身份登录并访问Securing URLs for Cron中提到的浏览器中处理程序的URL)一切顺利,但是一旦部署,我的应用程序永远不会超过OAuth2装饰器:
>使用一些调试打印语句……
import webapp2
...
YOUTUBE_RW_SCOPE = "https://www.googleapis.com/auth/youtube"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
print "Building youtube object"
print "Built youtube object"
youtube = build(YOUTUBE_API_SERVICE_NAME,YOUTUBE_API_VERSION)
print "Building decorator object"
decorator = OAuth2DecoratorFromClientSecrets(CLIENT_SECRETS,YOUTUBE_RW_SCOPE)
print "Built decorator object"
...
class FetchHandlerPage(webapp2.RequestHandler):
print "Entering FetchHandlerPage"
@decorator.oauth_required
def get(self):
print "Entering FetchHandlerPage:get"
gae_user_id = USER_ID
query_string = urlencode({'user_id': gae_user_id})
taskqueue.add(url='/fetchworker?' + query_string,method='GET')
> …这是我在GAE日志中部署后看到的内容(日志在最后一行停止,接下来没有任何反应):
2013-05-31 16:12:02.765 /fetch 302 1746ms 0kb AppEngine-Google; (+http://code.google.com/appengine)
0.1.0.1 - - [31/May/2013:13:12:02 -0700] "GET /fetch HTTP/1.1" 302 385 - "AppEngine-Google; (+http://code.google.com/appengine)" "myapp.appspot.com" ms=1747 cpu_ms=844 cpm_usd=0.000070 queue_name=__cron task_name=... loading_request=1 app_engine_release=1.8.0 instance=...
I 2013-05-31 16:12:02.444 URL being requested: https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest?userIp=0.1.0.1
E 2013-05-31 16:12:02.764 Building youtube object
E 2013-05-31 16:12:02.764 Built youtube object
E 2013-05-31 16:12:02.764 Building decorator object
E 2013-05-31 16:12:02.764 Built decorator object
E 2013-05-31 16:12:02.764 End static variables
E 2013-05-31 16:12:02.764 Entering FetchHandlerPage
I 2013-05-31 16:12:02.765 This request caused a new process to be started for your application,and thus caused your application code to be loaded for the first time. This requ
最佳答案
原文链接:https://www.f2er.com/python/439548.html