[英]Unable to retrieve an access token for Google's API using google-api-php-client
I'm trying to receive an access token from the Google API: 我正在尝试从Google API接收访问令牌:
$client = new Google_Client();
$client->setAuthConfig('service-account.json');
$client->setScopes('https://www.googleapis.com/auth/bigquery');
$client->setSubject($user_to_impersonate);
var_dump($client->getAccessToken());
I already tried with GOOGLE_APPLICATION_CREDENTIALS
but that returns null
, too: 我已经尝试过
GOOGLE_APPLICATION_CREDENTIALS
但是它也返回null
:
$client = new Google_Client();
putenv('GOOGLE_APPLICATION_CREDENTIALS=service-account.json');
$client->useApplicationDefaultCredentials();
$client->setScopes('https://www.googleapis.com/auth/bigquery');
$client->setSubject($user_to_impersonate);
All right... I saw what is happening... My json service account file was deprecated. 好吧...我知道发生了什么...我的json服务帐户文件已弃用。 I nedded to download it again, so it came with more vars on json file... The deprecated one has only 3 fields...
我希望再次下载它,因此它在json文件上带有更多的变量...不推荐使用的变量只有3个字段...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.