Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron job failed using CodeIgniter in Google Appengine

Using PHP framework in Google App Engine, Cron job failed when I using the index.php url with login:required. I used login:admin for cron.

Refer my app.yaml file

app.yaml

application: my-app
version: 1
runtime: php55
api_version: 1


- url: /.*
  script: index.php
  login: required

- url: /backup_cron/remindermail
  static_dir: backup_cron/remindermail
  login: admin

I don't want use no login and login: admin to my index.php load.

My app can see all those who has Gmail login only. With no login cron job worked fine.

Is it possible with login:required used in first loading page?

With login:required

log details:

HTTP/1.1" 302

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).

With no loginnd login:admin

Log details:

HTTP/1.1" 200

Success

like image 550
Sattanathan Avatar asked Feb 27 '26 02:02

Sattanathan


1 Answers

Crons can not access url's protected by login: required because they are not ran as users. From docs:

Note: While cron jobs can use URL paths restricted with login: admin, they cannot use URL paths restricted with login: required because cron scheduled tasks are not run as any user. The admin restriction is satisfied by the inclusion of the X-Appengine-Cron header described below.

Link here: https://cloud.google.com/appengine/docs/python/config/cron?hl=en#Python_app_yaml_Securing_URLs_for_cron

That being said, I suggest you use a specific handler for all your protected jobs. Or you could redirect non-logged in users.

like image 69
MeLight Avatar answered Feb 28 '26 17:02

MeLight