簡體   English   中英

無法使用google-api-php-client檢索Google API的訪問令牌

[英]Unable to retrieve an access token for Google's API using google-api-php-client

我正在嘗試從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());    

我已經嘗試過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);        

好吧...我知道發生了什么...我的json服務帳戶文件已棄用。 我希望再次下載它,因此它在json文件上帶有更多的變量...不推薦使用的變量只有3個字段...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM