I have the following code, modified from Google\'s documentation:
$GOOGLE_APPLICATION_CREDENTIALS = \"./[path].json\";
$_ENV[\"GOOGLE_APPLICATION
You need to use putenv()
(http://php.net/manual/en/function.putenv.php) instead of trying to use any of the methods you have used ($_ENV
or $_SERVER
).
Taken from https://github.com/google/google-api-php-client/blob/master/UPGRADING.md#google_auth_assertioncredentials-has-been-removed
// OR use environment variables (recommended)
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
$client->useApplicationDefaultCredentials();