googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
288 stars 347 forks source link

Example works fine from CLI, but fails when using crontab #72

Closed gshafer closed 3 years ago

gshafer commented 3 years ago

(Please search existing issues before creating a new one.)

Sample:

Expected Behavior

Returns name from spreadsheet

Actual Behavior

PHP Fatal error: Uncaught InvalidArgumentException: file "credentials.json" doe s not exist in /home/george/clock/vendor/google/apiclient/src/Client.php:960 Stack trace:

0 /home/george/clock/qs.php(33): Google\Client->setAuthConfig()

1 /home/george/clock/qs.php(79): getClient()

2 {main}

thrown in /home/george/clock/vendor/google/apiclient/src/Client.php on line 96 0

Steps to Reproduce the Problem

1.run from crontab 1. 1.

Specifications

gshafer commented 3 years ago

I fixed the path name to autoload.php:

require '/home/george/clock/vendor/autoload.php';

Now error is:

PHP Fatal error: Uncaught InvalidArgumentException: file "credentials.json" does not exist in /home/george/clock/vendor/google/apiclient/src/Client.php:960 Stack trace:

0 /home/george/clock/qs.php(33): Google\Client->setAuthConfig()

1 /home/george/clock/qs.php(79): getClient()

2 {main}

thrown in /home/george/clock/vendor/google/apiclient/src/Client.php on line 960

gshafer commented 3 years ago

My bad. Fixed the path to credentials.php and OK now.