How to set GOOGLE_APPLICATION_CREDENTIALS without using a path

ε祈祈猫儿з 提交于 2019-12-03 20:33:45

One can use keyFile key accepted as a config option while initializing clients.

Sample code taken from the offical api doc - https://github.com/googleapis/google-cloud-php

require 'vendor/autoload.php';

use Google\Cloud\Core\ServiceBuilder;

// Authenticate using a keyfile path
$cloud = new ServiceBuilder([
    'keyFilePath' => 'path/to/keyfile.json'
]);

// Authenticate using keyfile data
$cloud = new ServiceBuilder([
    'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
]);

In place of ServiceBuilder one can use any google client.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!