Reputation: 21
I have a google app engine. When i add a task to task queue to send email. I have this error:
Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).
my command is
taskqueue.add(url='/mypage/operation/task', params={'key': operation.key()}
Please help me to fix it.
Thanks.
Upvotes: 2
Views: 1768
Reputation: 12838
This specifically refers to which handler in your app.yaml
matches the task worker URL. It can specify no login requirement or login: admin
, but not login: required
.
This is a sanity check to ensure you understand the context in which tasks run. Tasks are permitted to bypass handlers decorated with login: admin
, but when they run, they will not have any user in context. users.get_current_user()
and users.is_current_user_admin()
won't work within the context of task execution, so putting tasks behind a login: required
handler doesn't make sense.
Upvotes: 7
Reputation: 15209
Without seeing your url setup it hard to say, but it appears /mypage/operation/task requires a user to be logged in to call it, but something that is sent to the task queue is gonna be called behind the scenes without a user logged in.
either remove the login requirement from that url, or make it an admin required url
Upvotes: 1