我需要Google Analytics Embed API的访问令牌。到目前为止,我尝试通过Google API PHP Client获取它的尝试无效:
require_once( 'vendor/autoload.php');
$jsonKeyFile = /path/to/key-file.json';
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$jsonKeyFile);
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/analytics.readonly');
$client->authorize();
echo 'accessToken: '.$client->getAccessToken();
不产生任何错误,但也不会产生令牌:´-(缺少什么?感谢您的帮助!