Google Cloud API - Application Default Credentials

前端 未结 5 1333
借酒劲吻你
借酒劲吻你 2021-02-04 07:04

I have the following code, modified from Google\'s documentation:

        $GOOGLE_APPLICATION_CREDENTIALS = \"./[path].json\";
        $_ENV[\"GOOGLE_APPLICATION         


        
5条回答
  •  温柔的废话
    2021-02-04 07:17

    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();
    

提交回复
热议问题