I'm trying to receive an access token from the 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:
$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. I nedded to download it again, so it came with more vars on json file... The deprecated one has only 3 fields...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.